Respuesta :
In python:
while True:
name = input("Please enter a name: ")
if name != "Nope":
print("Nice to meet you {}".format(name))
else:
break
Following are the program to the given question:
Program Explanation:
- Defining a header file.
- Defining a main method.
- Inside the method a string variable "name" and an integer variable "n" is declared.
- In the next step, a print message and define a loop that input and check its value.
- To check the input value a conditional statement is defined that check input value "Nope", if it's it break the loop, otherwise it print the value and input another value.
Program:
#include <iostream>//header file
using namespace std;
int main()//main method
{
string name;//defining string variable
int n=1;//defining an integer variable
cout<<"Please enter a name: (Nope to end)";//print message
while(n==1)//defining a while loop to that inputs and check the value
{
cin>>name;//input name value
if(name=="Nope")//use if that check name=="Nope"
{
n=0;//initilze n=0
break;//break the loop
}
else//else block
{
cout<<"Nice to meet you "<<name<<endl;//print input value with message
cout<<"Please enter a name: (Nope to end)";//print message
}
}
return 0;
}
Output:
Please find the attachment file.
Learn more:
brainly.com/question/18129358
