Answer to Question #253362 in C++ for Angelie Suarez

Question #253362

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.


1
Expert's answer
2021-10-19T10:53:45-0400
#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;
}

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
APPROVED BY CLIENTS