Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual Basic Net Database Programming

Authors: Rod Stephens

1st Edition

0789726815, 978-0789726810

More Books

Students also viewed these Databases questions