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
×