• Follow Us

Calculate your age program in C

Calculate your age program in C

#include<stdio.h>
int main()
{
    int current_year,b,d;
    printf("Enter Year of Birth\n");
    scanf("%d",&b);
    printf("Enter Current year\n");
    scanf("%d",&current_year);
    if(current_year==0)
    {
        d=100-b;
    }
    else if(current_year>b)
    {
        d=current_year-b;
    }
    else
    {
        d=(100+current_year)-b;
    }
    printf("Your age is %d",d);
    return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *

Shopping cart