Answer to Question #44822 in C++ for Yahya

Question #44822
//3. Read in characters from the user until user enters 'z', then print out how many a's were entered The below program does not count the number of 'a' the user has inputted. Please see the code below. Do I need to use array or I can do it without array, if yes please let me know how without using array. #include <iostream> using namespace std; void main () { char letter; int x=0; cout << "Please enter letter(s): "; cin >> letter; while (letter=='a') { x = letter+1; if (letter!= 'z') { cin >> letter; } } cout << "The number(s) of letter 'a' entered is/are: " << x << endl; system ("pause"); }
Expert's answer

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!


No comments. Be first!

Leave a comment

Ask Your question

New on Blog