64 778
Assignments Done
99,3%
Successfully Done
In September 2018

Answer to Question #3318 in C++ for mukunda

Question #3318
Write a program to count number of vowels in a given string.
Expert's answer
#include <iostream>
#include <cstring>
using namespace std;

int main()
{
char str[] = "hello, world!";

int vowels_ctr = 0;
for (char *it = str; *it; ++it) {
& switch (*it) {
& case 'a': case 'A':
& case 'e': case 'E':
& case 'o': case 'O':
& case 'i': case 'I':
& case 'u': case 'U':
& ++vowels_ctr;
& }
}
cout << "The number of vowels in <" << str << "> is " << vowels_ctr << endl;
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions