Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to determine if the input is an integer in C language? If not, re-enter it
How to determine if the input is an integer in C language? If not, re-enter it

Is this one question or two questions? Here I will write two questions first:

Judge whether it is a leap year:

main()

{

int Year ;

scanf(“%d”,&Year);

if(Year<1000||Year>9999)

{

if((Year%4==0 && Year%100!=0) || Year%400==0)

printf("%d year is a profitable year",Year);

else

printf("%d year is not a run year",Year);

else

{

printf("Please enter the correct year");

}

}

Judge whether it is an integer:

main()

{

int Number;

scanf(“%d”,&Number);

while ((int)Number!=Number)

{ //Force the input book to an integer. If the two numbers are consistent, the input is an integer

printf("No Integer, please re-enter: ");

scanf ("%d",&Number);

}

}