C Language program to take birth year and tells age

Views: 166   

Following program shows you how to take birth year and tells age.
In this program we get birth year from user and tells their age using currentYear - birthYear

#include <stdio.h>
int main(void) {
    int birthYear;
    printf("Please enter your birth year:");
    scanf("%d", &birthYear);
    int age = 2018 - birthYear;
    printf("Your age is %d \n", age);
}

Output:

Please enter your birth year: 1991
Your age is 27
On By