- Back to Home »
- C Program To Calculate What Year Someone Will Turn A Specific Age
Posted by : Unknown
1: /* Program to calculate what year someone will turn a specific age */
2: #include <stdio.h>
3: #define TARGET_AGE 88
4:
5: int year1, year2;
6:
7: int calcYear(int year1);
8:
9: int main(void)
10: {
11: // Ask the user for the birth year
12: printf("What year was the subject born? ");
13: printf("Enter as a 4-digit year (YYYY): ");
14: scanf(" %d", &year1);
15:
16: // Calculate the future year and display it
17: year2 = calcYear(year1);
18:
19: printf("Someone born in %d will be %d in %d.",
20: year1, TARGET_AGE, year2);
21:
22: return 0;
23: }
24:
25: /* The function to get the future year */
26: int calcYear(int year1)
27: {
28: return(year1+TARGET_AGE);
29: }
_edited.jpg)
