Determine what's wrong in this code and change it.
#include
using namespace std;
int main(){
cout<<"Hello there, please tell me your name?";
char name[50];
cin>>name;
cout<<" Thank you, "< 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<}
#include <iostream>
using namespace std;
int main() {
cout<<"Hello there, please tell me your name: ";
char name[50];
cin >> name;
cout << "Thank you, " << name <<". Enter 1 or 2: ";
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: ";
int year;
cin >> year;
cout << "Your age is: " << 2021 - year << '\n';
return 0;
}
Comments
Leave a comment