MENU
Question -

Write a function in C + + to count and display the no of three letter words in the file “VOWEL.TXT”.
Example :
If the file contains :
A boy is playing there. I love to eat pizza. A plane is in the sky.
Then the output should be : 4



Answer -

#include
 #include
 void wordcount()
 { char word[80];
 int cnt=0;
 ifstream fl;
 f1.open("VOWEL.TXT");
 while (fl>>word)
 {
 if (strlen(word) == 3)
 {
 cnt++;
 cout<
 }
 }
 cout<<" number of three letter words = ”<
 f1.close();
 }

Comment(S)

Show all Coment

Leave a Comment

Free - Previous Years Question Papers
×