How is that following program executes function birthYear() before currYear()? My understanding is that statement outputAge(age(currYear(), birthYear())) is the first to be executed, so, age(currYear(), birthYear()) is the first function to be executed. For been so, function currYear() should be executed before birthYear().
#include <iostream>
int currYear()
{
std::cout << "Enter current year: \n";
int currYear;
std::cin >> currYear;
return currYear;
}
int birthYear()
{
std::cout << "Enter year of birth: \n";
int birthYear;
std::cin >> birthYear;
return birthYear;
}
int age(int x, int y)
{
return x - y;
}
void outputAge(int x)
{
std::cout << "Age is:\n" << x << std::endl;
}
int main()
{
outputAge(age(currYear(), birthYear()));
return 0;
}