10:53 AM
Write a Program of COUNT NO OF OCCURRENCES OF A CHARACTER IN A STRING USING getchar() AND putchar().

Write a Program of COUNT NO OF OCCURRENCES OF A CHARACTER IN A STRING USING getchar() AND putchar().

 
#include<stdio.h>
main()
{
char name[20];
int i,count=0;
clrscr();
for(i=0;i<20;i++)
{
name[i]=getchar();
putchar(name[i]);
if(name[i]=='\n')
break;
else if(name[i]=='a')
count++;
}
printf("\nThe number of a's in name :%d",count);
getch();
return 0;
}
Views: 78 | Added by: vijoriya | Tags: Count, INSTRING, character, putchar, program, OCCURRENCES, getcha | Rating: 0.0/0
Total comments: 0
avatar