Write a program in C++ to input your name, city and age during program execution and then
print it on the screen. Your output should look like as given below: (where John Doe is name,
city= London and age=40)
#include <iostream>
#include <string>
using namespace std;
int main() {
string name;
string city;
int age;
cout << "Enter your name: ";
getline(cin, name);
cout << "Enter your city: ";
cin >> city;
cout << "Enter your age: ";
cin >> age;
cout << endl;
cout << "(where " << name << " is name," << endl
<< "city= " << city << " and age=" << age << endl;
return 0;
}
Comments
Leave a comment