Answer to Question #44823 in C++ for Yahya

Question #44823
//3. Read in characters from the user until user enters 'z', then print out how many a's were entered Please see the below code. However the code is not counting the number of 'a' the user has inputted. Would I have to use array? or is there a way to do it without array if yes please help me thanks. #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

Not answered

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