Friday, 1 November 2013

Count Repitation of a Character from String


//count repitation of a character from string
Count Repetation of Character from Given String 
#include<stdio.h>
#include<conio.h>

void main()
{
int i;
char ch[10],c;
int count=0;
clrscr();
printf("Enter any string= ");
gets(ch);
printf("Enter any character from string= ");
c=getch();
for(i=0;ch[i]!='\0';i++)
{
if(ch[i]==c)
{
count++;
}
}
printf("\nrepitation of %c = %d times",c,count);
getch();
}

Output:


Repeted String

No comments:

Post a Comment