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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!