Answer to Question #317876 in C++ for Two

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.

1
Expert's answer
2022-03-25T04:37:02-0400


#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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog