MENU
Question -

Write a function EUCount ( ) in C++, which should read each character of a text file IMP TXT, should count and display the occurrence of alphabets E and U (including small cases e and u too).
Example:
If the file content is as follows ;
Updated information is simplified by official websites.
The EUCount() function should display the
output as
E:4
U:1



Answer -

void EUCount ()
 {
 fstream obj;
 obj. open("IMP.TXT");
 char ch;
 int i = 0 , sumE=0, sumU=0 ;
 while (obj. get (ch)! =0)
 {obj. get (ch);
 if(ch=="E"||ch=="e")
 SumE=sumE+l;
 if(ch=="U" ??ch =="u")
 SumU=SumU+l;
 } cout << "E : " «sum E<
 cout<<"U:"<
 }

Comment(S)

Show all Coment

Leave a Comment

Free - Previous Years Question Papers
×