
Please use easy logic with proper indentations and comments for understanding!. Coding should be in C++. I am providing an
1
2
3 #include <iostream>
4 #include <fstream>
5 #include <cstdlib>
6
7 using namespace std;
8
9 void status(string st,int &vowel,int &consonant, int &other)
10 {
11
12 //if it is vowel
13 if ((st[0]=='a' || st[0] == 'e' || st[0] == 'i' || st[0] == 'o' || st[0]=='u') || (st[0]=='A' || st[0] == 'E' || st[0] == 'I' || st[0] == 'O' || st[0]=='U') )
14 vowel++; //incrementing vowels by 1
15 else if(isalpha(st[0]))
16 consonant++; //increment consonants by 1
17 else
18 other++; //increment others by 1
19 }
20 // main that will read the file
21 int main()
22 {
23 //word stores the word, filename stores the name of the file
24 string word;
25 string filename;
26 int vowels = 0,
27 consonants = 0,
28 others = 0;
29 ifstream file("file.txt");
30 // extracting words from the file using stream operator
31 cout<<"input string : ";
32 while (file >> word) { //while there are words to read
33 cout << word <<" "; //output word
34 status(word,vowels,consonants,others); //call function status and pass the word and other variables as parameters
35 }
36 //Printing the total vowel and consonants
37 cout<<"\n"<<vowels<<" words begin with a vowel "<<endl;
38 cout<<consonants<<" words begin with a consonant "<<endl;
39 cout<<others<<" other words were found "<<endl;
40 return 0;
41 }



Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 2 images

- USING C++ Please fix the errors in the code (image attached) with the failed test warning (image attached). Thank you! Write a program that removes all non-alphabetic characters from the given input. Ex: If the input is: -Hello, 1 world$! the output is: Helloworld Your program must define and call the following function that takes a string as a parameter and returns the string without any non-alphabetic characters.string RemoveNonAlpha(string userString)arrow_forwardYou must use an STL container (such as list or vector) for this assignment; solutions not using an STL container are not acceptable. Write a C++ program to get up to ten integers from the user, store them in an STL container, and then calculate and display: (1) the mean (2) the variance of the population (see https://www.statisticshowto.com/population-variance/ for the formula and an example) (3) the standard deviation (the square root of the variance)arrow_forwardProvide full C++ main.cpp, fraction.cpp, fraction.harrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





