-->
Showing posts with label WAP to count total number of particular character present in a string.. Show all posts
Showing posts with label WAP to count total number of particular character present in a string.. Show all posts

WAP to count total number of particular character present in a string.

//WAP to count total number of particular character present in a string.
#include<stdio.h>
include<conio.h>
void main()
{                                                           
char name[30], c;                                                    
int i,count=0;
printf("enter string\n");
gets(name);
printf("enter a character \n");
c=getchar();
for(i=0;name[i]!='\0';i++)
{
if(name[i]==c)
{
  count++;
}
}
printf("total character present=%d\n",count);
getch();
}