Write program in c++ (Count vowels and consonants, file input, nested-loops, swi
ID: 3679971 • Letter: W
Question
Write program in c++
(Count vowels and consonants, file input, nested-loops, switch statement)
Assume letters A, E, I, O, and U as the vowels. Write a program that reads strings from a text file, one line at a time, using a while-loop. You do the following operations within each loop: Read the one line from the input file and store it in a string; Count the number of vowels and consonants (using either while-loop or for-loop) in the string The while-loop will terminate when the end-of-file is reached. After the loop is finished, display the total number of vowels and consonants in the text file. [A text file, named “ass4_Q1_input.txt”, is provided as your testing input file.]
Explanation / Answer
if(ch==' ')
space++;
tot_char++;
consonant=(tot_char-vowelCount-space);
file<<vowelCount;
file<<consonant;
#include<fstream>Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.