My program is showing "it is a leap year" for every output. Please let me know where i am committing an error??
#include<stdio.h>
#include<conio.h>
void main()
{
int a;
clrscr();
printf("\n Enter the year : ");
scanf("%d",a);
if (a%400 == 0)
printf("\n It is a leap year");
else
if (a%100 == 0)
printf("\n It is not a leap year");
else
if (a%4 == 0)
printf("\n It is a leap year");
else
printf("\n It is not a leap year");
getch();
}
The scanf()
function requires you pass the address of your variable:
scanf("%d",&a);