#include<iostream.h>
#include<conio.h>
void main ( )
{
char a [20], ch ;
int i , count ;
cout<< "\n Enter a String : " ;
cin>>a;
cout<<"\nEnter a character to check its frequency in given string :";
cin>>ch;
i = 0 ;
while (a[i]!='\0')
{
if ( ch == a [ i ] )
count = count +1 ;
i = i + 1 ;
}
cout<< "\nFrequency of given letter is "<<count ;
getch ( ) ;
}
#include<conio.h>
void main ( )
{
char a [20], ch ;
int i , count ;
cout<< "\n Enter a String : " ;
cin>>a;
cout<<"\nEnter a character to check its frequency in given string :";
cin>>ch;
i = 0 ;
while (a[i]!='\0')
{
if ( ch == a [ i ] )
count = count +1 ;
i = i + 1 ;
}
cout<< "\nFrequency of given letter is "<<count ;
getch ( ) ;
}
0 comments:
Post a Comment