Get the App
SLTechnology News&Howtos  ›  Development  › 

How can C language tell whether it is a leap year or not?

Shulou Source: shulou.com Published: 2022-06-01 01:50:55 10月01日 Update

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.

Tags: Leap year language year knowledge input content article value example easy to operate integer article easy to understand more user look results industry information information channel Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux MariaDB Huawei Docker Redmi