Question
C++ code do while loop issue. The code I posted works but when it prompts the user if they want to try against with another
C++ code do while loop issue. The code I posted works but when it prompts the user if they want to try against with another sentence, it only takes the Y and goes straight into another loop, without letting me enter a new sentence. I need it to be able to take the Y response from a user and then let me enter another sentence. do { cout<<"Enter a sentence:"; //user input sentence cin.getline(str,80); int wordsCount = 0;
for (int i=0;str[i] !='\0'; i++) //making space for null { if (str[i] == ' ')//checking for space { wordsCount++; } } my print out code.....
//ask user to enter another sentence cout << "Try Again? (Y/N) "; cin>>input;
}while ((input == 'y') ||( input == 'Y')); return 0;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started