A text file “NOTES.TXT” is created. Reading this file create a C++ function to count the number of words having first character capital.

void countCapitalWord()
{
ifstream fin(“NOTES.TXT”);
char word[25];
int count=0;
while(!fin.eof())
{
fin>>word;
if (isupper(word[0]))
count++;
}
fin.close();
cout<<"There are "<<count<<" words in file which starts with Capital Letter";
}

void main()
{
countCapitalWord();
}





No comments

Post your comments

Powered by Blogger.