//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;
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();
}
No comments:
Post a Comment