Question #317876

Using a do…while() loop, continuously scan for characters (one per line) and print it out afterwards.



The loop shall terminate due to either of the following reasons:



The inputted character is a vowel



The number of inputted characters has already reached 5.

Expert's answer



#include <iostream>


using namespace std;


int main()
{
	
	char letter;
    int count=0;
    do{
		cout<<"Enter letter: ";
        cin>>letter;
		cout<<letter<<"\n";
        char c = tolower(letter);
        if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' ||
			c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U') {
            break;
        }
        count++;
    } while(count<5);


	system("pause");
	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!

LATEST TUTORIALS
APPROVED BY CLIENTS