I'm very very new at programming, and I am attempting to make a simple (I thought) program that asks the user the current year, their age. It would then output the year in which they were born. +/- a year, depending on when the birthday falls... But I'll fix that later.
The issue is, BirthYear *always* returns 23. I can't figure it out. I suspect I'm doing something wrong here:
Code:
int BirthYear = CurrentYear - Age;
But here is the complete program in case that is not the problem.
Code:
#include <iostream>
using namespace std;
int AskWhatYear ();
int AskAge ();
int main()
{
int Age;
int CurrentYear;
AskAge();
AskWhatYear();
int BirthYear = CurrentYear - Age;
cin.get();
cout<<"\nYou were probably born in "<< BirthYear;
cin.get();
}
int AskAge() // Asks the users age.
{
int Age;
cout<<"\nPlease enter your age: ";
cin>> Age;
cin.ignore();
return Age;
}
int AskWhatYear() // Asks the user what year it is.
{
int CurrentYear;
cout<<"\nPlease enter the current year: ";
cin>> CurrentYear;
cin.ignore();
return CurrentYear;
}
Thanks in advance!
I'm sure there are other noob mistakes in there that work, but aren't the ideal way to do it. I'm open to al suggestions