InterviewSolution
Saved Bookmarks
| 1. |
An assignment, Kumar has written a C++ program which reads a line of text and print the number of vowels in it. What will be his program code? |
|
Answer» # include<iostream> # include<cstdio> # include<cctype> using namespace std; int main() { char line(80); int i,vowel=0; puts(Enter a string"); gets(line); for(i=0;line[i]!='\0';i++) switch(to lower(line[i])) { case 'a': case 'e': case 'i': case 'o': case 'u': vowel++; } cout<<"The number of vowels is"<<vowel; } |
|