年是包括366天的一年。每四年,我们将经历leap年。
我们将执行的逻辑是查找用户通过控制台获得的给定年份是否是飞跃的-
if (( year%400 == 0)|| (( year%4 == 0 ) &&( year%100 != 0)))
如果满足此条件,则给定年份为a年。否则不是。
以下是在If条件的帮助下检查leap年的C程序-
#include <stdio.h>
int main(){
int year;
printf("Enter any year you wish \n ");
scanf(" %d ", &year);
if (( year%400 == 0)|| (( year%4 == 0 ) &&( year%100 != 0)))
printf("\n %d is a Leap Year. \n", year);
else
printf("\n %d is not the Leap Year. \n", year);
return 0;
}输出结果执行以上程序后,将产生以下结果-
Enter any year you wish 2045 2045 is not the Leap Year.