How can C language tell whether it is a leap year or not?
This article mainly introduces how to judge whether the C language is leap year related knowledge, detailed and easy to understand, simple and fast operation, has a certain reference value, I believe that everyone reading this C language how to judge whether leap year articles will be harvested, let's take a look at it.
The user enters a year to determine whether it is a leap year.
examples
#include
int main(){
int year;
printf("Enter year: ");
scanf("%d",&year);
if(year%4 == 0)
{
if( year%100 == 0)
{
//Here if the integer is 400 is leap year
if ( year%400 == 0)
printf("%d is leap year", year);
else
printf("%d is not leap year", year);
}
else
printf("%d is leap year", year );
}
else
printf("%d is not leap year", year);
return 0;
}
Run Results:
Input year: 19901990 is not a leap about "C language how to judge whether it is a leap year" The content of this article is introduced here, thank you for reading! I believe everyone has a certain understanding of the knowledge of "how to judge whether C language is leap year or not." If you still want to learn more knowledge, please pay attention to the industry information channel.