Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report