Hi there this is a very easy problem but i can't get it correctly here's the code;
Code:
#include <iostream>
using namespace std;
int main(void)
{
int yr_of_brth, crnt_yr;
cout << "Year of Birth" << endl;
cin >> yr_of_brth;
cin.ignore();
cout << "\n";
cout << "Current Year" << endl;
cin >> crnt_yr;
cin.ignore();
cout << "\n";
cout << "your age is: " << abs(yr_of_brth - crnt_yr) << endl;
cin.get();
}
Output:
Year of birth
62
Current Year
99
Your age is: 37
-----another run of the program-----
Output:
Year of birth
62
Current Year
00
Your age is: 38
the thing that i dont get is if I input 62 for year of birth and current year for 00 i got a answer of 62 not 38..... how can i get 38 as a answer because this program requires only the last two numbers in year.... any help there? thanks