147k views
2 votes
You need the user of a program to enter a customer's last name. Write a statement that prompts the user to enter this data and assigns the input to a variable.

User Rfanatic
by
6.4k points

1 Answer

1 vote

Answer:

The statement is cin>>lastname;//In c++.

lastname=str(input("Enter the last name\\")) #statement in python.

Following is the C++ code:-

#include <iostream>

#include<string>

using namespace std;

int main() {

string lastname;//string variable to hold lastname.

cout<<"Enter lastname of the user"<<endl;//printing a message.

cin>>lastname;//taking input of the lastname..

cout<<lastname;//printing lastname to check the value.

return 0;

}

Output:-

Enter lastname of the user

khurana

khurana

Step-by-step explanation:

You can assign the input to the lastname by using cin in c++ and input in python and creating a scanner class object in java.

User Bernardo Meurer
by
5.4k points