1#include <stdio.h>
2#include <string.h>
3
4int main()
5{
6 char s[1000],c;
7 int i,count=0;
8
9 printf("Enter the string : ");
10 gets(s);
11 printf("Enter character to be searched: ");
12 c=getchar();
13
14 for(i=0;s[i];i++)
15 {
16 if(s[i]==c)
17 {
18 count++;
19 }
20 }
21
22 printf("character '%c' occurs %d times \n ",c,count);
23
24
25
26 return 0;
27}
28