Display ‘Hello there, please tell me your name?’ and accepts an input (name) from the user. It will then display ‘Thank you, [name] for being here. See you again next time!’
When an input is 1, display ‘True’. When an input is 2, display ‘False’. When an input is other than 1 or 2, display ‘Invalid’.
Ask for a birth date then compute and display the exact age in a year.
#include<iostream>
using namespace std;
int main(){
cout<<"Hello there, please tell me your name?";
char name[50];
cin>>name;
cout<<" Thank you, "<<name<<" for being here. See you again next time!\n";
cout<<"Enter 1 or 2\n";
int n;
cin>>n;
if(n==1){
cout<<"True\n";
}
else if(n==2){
cout<<"False\n";
}
else{
cout<<"Invalid\n";
}
cout<<"Enter your birth year:\n";
int year;
cin>>year;
cout<<"Your age is: "<<2021- year<<endl;
}
Comments
Leave a comment