183k views
0 votes
write a simple computer program that asks a user to input their name and email address and then displays a message that tells the person that you will be contacting them using the email address they entered

1 Answer

4 votes

Answer

int main()

{

std::string name = "";

std::string email_address = "";

std::cout << "Please enter your name: ";

std::cin >> name;

/// New line.

printf("\\");

std::cout << "Please enter your email-address: ";

std::cin >> email_address;

/// New line.

printf("\\");

std::cout << "Thank you, " << name << "." << " I will be contacting you at your provided email address (" << email_address << ")" << " as soon as possible!";

/// EXIT_SUCCESS.

return 0;
}

Step-by-step explanation

std::string is a type that holds a string or alphanumerical content.

std::cout prints text to the console.

std::cin accepts input from the keyboard.

printf is a C function that allows you to print to the console.

Written for C++.

User Satendra Rawat
by
4.7k points