Answer to Question #305495 in C++ for Tgi

Question #305495

Write a c++ program that takes your name from keyboard and display the following if your name has 10 character your name is too long if it comprise between 5 and 9 character your name is medium if it comprise less than 5 character your name is too Short

1
Expert's answer
2022-03-03T09:59:16-0500
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string name;
	do
	{
		cout << "\nPlease, enter your name (q - exit program): ";
		cin >> name;
		if (name != "q")
		{
			if (name.size() == 10)
				cout << "Your name is too Long";
			else if (name.size() >= 5 && name.size() <= 9)
				cout << "Your name is Medium";
			else if (name.size()<5)
				cout << "Your name is too Short";
		}
	} while (name != "q");	
}

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