I’m having problem with a simple C program. Even if I enter a year between 1000 and 1999 it still displays invalid year. Please tell me what’s happening??
#include <stdio.h>
main()
{
int year;
c:
printf("\n\nEnter a Year: ");
scanf("%d", year);
if ((year < 1000) || (year > 1999))
{
printf("\n\nInvalid Year");
goto c;
}
convert(year);
}
convert(int year)
{
printf("%d", year);
}
You need to pass an address to
scanf, i.e.:Note the ampersand.