//Program to find occurance of given character in string.
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char str[20],c;
int o,i,l;
clrscr();
printf("program to find occurance of given character in string");
printf("\n Enter the string: ");
gets(str);
l=strlen(str);
printf("Please enter the character whose number of occurances u want to find: ");
c=getche();
o=0;
for(i=0;i<l;i++)
{
if(str[i]==c)
{
o=o+1;
}
}
printf("\n the number of occurances of given character is %d",o);
getch();
}
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char str[20],c;
int o,i,l;
clrscr();
printf("program to find occurance of given character in string");
printf("\n Enter the string: ");
gets(str);
l=strlen(str);
printf("Please enter the character whose number of occurances u want to find: ");
c=getche();
o=0;
for(i=0;i<l;i++)
{
if(str[i]==c)
{
o=o+1;
}
}
printf("\n the number of occurances of given character is %d",o);
getch();
}