#include<stdio.h>
#include<conio.h>
void main()
{
char str[10],ch;
int i=0,count=0;
clrscr();
printf("Enter string:");
gets(str);
printf("Enter character:");
scanf("%c",&ch);
while(str[i]!='\0')
{
if(str[i]==ch)
{
count++;
}
i++;
}
printf("\n Count=%d",count);
getch();
}
(Note: Any other correct logic shall be considered).
0 Comments