sorry, might be really dumb just started to learn C. it's a basic check if the input year is a leap year or not. I don't understand where I am going wrong. the executable starts but as soon as I input a year and press enter it closes.
I tried to remove the return 0;
by using void main
instead cause I thought it is causing the abrupt crash. I don't know enough to try anything else.
#include <stdio.h>
int main() {
int year;
printf("Enter year below\n");
scanf("%d", &year);
if (year % 4 == 0) {
if (year % 100 == 0) {
if (year % 400 == 0)
printf("%d is a Leap year", year);
else
printf("%d is not a Leap year", year);
} else
printf("%d is a Leap year", year);
} else
printf("%d is not a Leap year", year);
return 0;
}
I expected it to be able to check the leap year but it just crashes.