Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Write a program to count the occurrences of a character in a string using pointers.

Hard

Problem Statement

Write a program to count the occurrences of a character in a string using pointers.

Sample Input

str = 'hello world', ch = 'o'

Sample Output

Occurrences of 'o' = 2

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
#include <stdio.h> int main() { char str[] = "hello world"; char ch = 'o'; // Logic to count occurrences return 0; }
Log in or sign up to run or submit your code.Log inSign up
Input
str = 'hello world', ch = 'o'
Expected Output
Occurrences of 'o' = 2