Previous lesson displays static information. In this lesson we are going to use the dynamic display of information. #include <iostream> using namespace std; int main(){ //we declare data types here. string name; //fist we need to display the Instruction for the user."Enter your name: cout<<"Enter your name: //we call the "name" variable to get the user input. we use "cin" to get the user input cin>>name; //we call again our variable name to display what the user input. cout<<"Your name is: "<<name; //try it and try to complete the personal information. add the following variables //age, gender, address, email, mobile }
#include <iostream>
#include <string>
using namespace std;
int main(){
//we declare data types here.
//add the following variables
//age, gender, address, email, mobile
string name;
int age;
string gender;
string address;
string email;
string mobile;
//fist we need to display the Instruction for the user."Enter your name:
cout<<"Enter your name: ";
//we call the "name" variable to get the user input. we use "cin" to get the user input
cin>>name;
cout<<"Enter your age: ";
cin>>age;
cout<<"Enter your gender: ";
cin>>gender;
cout<<"Enter your address: ";
cin>>address;
cout<<"Enter your email: ";
cin>>email;
cout<<"Enter your mobile: ";
cin>>mobile;
//we call again our variable name to display what the user input.
cout<<"Your name is: "<<name<<"\n";
cout<<"Your age is: "<<age<<"\n";
cout<<"Your gender is: "<<gender<<"\n";
cout<<"Your address is: "<<address<<"\n";
cout<<"Your email is: "<<email<<"\n";
cout<<"Your mobile is: "<<mobile<<"\n";
cin>>email;
}
Comments
Leave a comment