/* * age2.c * By John Stile * Chapter2 * Ask use for the year they were born * Capture the users entery and store it as an integer variable. * Tell the user what year they entered */ #include // include functions in library stdio.h when compiling this code. int birthyear(void) // header for function birthyear, takes nothing, returns int { int birthdate; // declare variable birthdate printf(" What year where you born? (i.e 1969 )"); // Ask user for the year scanf( "%d", &birthdate); // Store input at memory address of int variable birthdate return birthdate; // Return value of int variable birthday to caller } void age(int year) // header for function age, takes an integer by the caller, and returns nothing. { printf("You are %d years old\n", 2007-year); // output the age of the user } int main(void) // header for funciton main, { int birth; // declare intiger variable birth birth=birthyear(); // Assign return value from function birthyear to int variable birth printf("You entered %d\n", birth); // print the value stored in birth age(birth); // call function age, sending it the int value stored in birth. return 0; // return in value 0 to caller of main (exit statis of program) }