So I made a program that checks if a year is a leap year or not.
Here's the code.
#include <stdlib.h>
int year[30];
int leapOrNot()
{
if(*year % 4 == 0)
{
if(*year % 100 == 0)
{
if(*year % 400 == 0)
printf("%d is a leap year.\n", year);
else
printf("%d is not a leap year.\n", year);
}
else
printf("%d is a leap year.\n", year);
}
else
printf("%d is not a leap year.\n", year);
return 0;
}
int main()
{
printf("What year?\n");
scanf("%d", &year);
leapOrNot(year);
return 0;
}
When I input any number, it will check if it's a leap year or not, but instead of saying " is a leap year." or " is not a leap year.", it says "4225408 is a leap year" or "4225408 is not a leap year."
Here are 2 images that show my problem.
What's causing this? I even tried using long data type and I still have the same problem.
Aucun commentaire:
Enregistrer un commentaire