Answer to Question #308780 in C++ for Diya

Question #308780

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)

1
Expert's answer
2022-03-10T02:09:51-0500
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog