Ask a user for his/ her birth year encoded as two digits (like"62")and for the current ,also encoded as two digits (like"99"). Write a c++ program to find the users current age in years
Input format:
Input consists of 2 Integers.
The first integer corresponds to the last 2 digits of the birth year.
The second integer corresponds to the last 2 digits of the current year.
Output: print the user's current age
Answers
Answered by
1
Answer:
????????
Explanation:
?????????????????????????????????????????????????????¿??????????????????????????????????????¿????????????
Answered by
1
Answer: x=Last two digits of birth year
y=Last two digits of current year
by=Birth year
cy=Current year
ca=Crrent age
#include<iostream>
using namespace std;
int main()
{
int x,y,by,cy,ca;
cin>>x>>y;
if(x>y)
{
by=1900+x;
cy=2000+y;
ca=cy-by;
cout<<ca;
}
else
{
by=2000+x;
cy=2000+y;
ca=cy-by;
cout<<ca;
}
}
Similar questions