MENU
Question -

Write a function AECount() in C++, which should read each character of a text file NOTES. TXT, should count and display the occurrence of alphabets A and E (including small cases a and e too).
Example :
If the file content is as follow :
CBSE enhanced its CCE guidelines further.
The AECount() function should display the output as
A:1
E:7



Answer -

Void AECount ()
 {
 Fstream obj;
 Obj.open ("NOTES.TXT", ios :: in) ;
 char x;
 int i=o, Sum A=0, Sum E=0,
 while (obj.get (ch)!=0)
 {
 obj . get (x) ;
 if (x=="A"||? x=="a")
 SumA =SumA+l;
 if(x=="E"|| x =="e")
 SumE=sumE+l;
 }
 cout<<"A:"<
 Cout<<"E:"<< SumE;
 }

Comment(S)

Show all Coment

Leave a Comment

Free - Previous Years Question Papers
×