-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathq1.cpp
More file actions
22 lines (22 loc) · 656 Bytes
/
Copy pathq1.cpp
File metadata and controls
22 lines (22 loc) · 656 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include<bits/stdc++.h>
using namespace std;
#define MAX_LIMIT 1000
#define CURRENT_YEAR 2021
int main()
{
string name;
int age;
cout<<"What is your name?"<<endl;
cout<<"> ";
// using getline to input whole string until new line char occurs
getline(cin,name);
cout<<"Hello, "<<name<<"!"<<endl;
cout<<"What year you were born?"<<endl;
cout<<"> ";
//Ensure birth year is not greater than current year
cin>>age;
// Not including current year
age=CURRENT_YEAR-age-1;
cout<<"Congratulations, you are "<<age<<" years old!"<<endl;
return 0;
}