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");

}
1
Expert's answer
2014-08-12T10:34:59-0400
The answer to the question is available in the PDF file https://www.assignmentexpert.com/https://www.assignmentexpert.com/homework-answers/programming-answer-44822.pdf

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
APPROVED BY CLIENTS