//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");
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment