Michael junior Jacob (ENM213-0158/2023)AEROSPACE ENGINEERING
//this program calculates how old the user is and tells the user if the year was a leap year//
#include<stdio.h>
#define currentyear 2024
int main()
//defining of variables//
int yearborn,age;
//asking the user his birth year//
printf("what year were you born?\n");
scanf("%d",&yearborn);
if(yearborn>currentyear)
{printf("you're not yet born!\n");
printf("would you like to try again?\n");
printf("what year were you born?\n");
scanf("%d",&yearborn);
age=currentyear-yearborn;
//printing the output on the screen//
printf("this year on your birthday you will turn %d",age);
if ((yearborn %4)==0)
printf("you were born in a leap year");
Return 0
/tmp/lCvUBmzgJE.o
what year were you born?
2005
this year on your birthday you will turn 19
=== Code Execution Successful===
//this program calculates how old the user is and tells the user if the year was a leap year//
#include<stdio.h>
#define currentyear 2024
int main()
//defining of variables//
int yearborn,age;
//asking the user his birth year//
printf("what year were you born?\n");
scanf("%d",&yearborn);
age=currentyear-yearborn;
if(yearborn>currentyear)
printf("you're not yet born!\n");
else
printf("you're %d years old!\n",age);
/testing for leap year/
if ((yearborn%4)==0)
//printing the output on the screen//
printf("you were born in a leapyear!\n");
else
printf("your birth year wasn't a leap year");
}
}
Return 0
/tmp/k93GaLWIXl.o
what year were you born?
2005
you're 19 years old!
your birth year wasn't a leap year
=== Code Execution Successful ===