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
#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");
}
Comments
Leave a comment