Your Ad Here

Friday, February 27, 2009

Write a C++ program to make the frequency count of letters in a given text.

#include(iostream.h) // place this '<' & '>' instead of '(' & ')' before iostream.h
#include(conio.h)
#include(stdio.h)
void main( )
{
chat st[80];
int i, ct=0,sp=0;
clrscr( );
cout<<"Enter the required information:";
gets(st); for(i=0; st[i]!='\0'; i++)
{
ct++;
if(st[i]==' ')
sp++;
}
cout<<"Total Letters present in the given text :"<< ct-sp;
getch( );
}

Here the variable 'sp' is for counting space and 'ct' is for counting characters.

Note:- If u have any doubt regarding this program or logic, please feel free to contact me.

No comments:

Post a Comment