Notice
Recent Posts
Recent Comments
Creative Code
ordinaryLeap3.c(윤년,평년 판별 삼항연산자) 본문
#include <stdio.h>
// 윤년인지 아닌지 판별
int main(void)
{
int year;
printf("year :");
scanf("%d",&year);
/*
if ((year %4 == 0 || year%400 ==0) && year%100 != 0){
printf("%d is a leap year \n",year);
} else {
printf("%d is a ordinary year \n",year);
}
*/
printf("%d is a %s year \n",year,
((year %4 == 0 || year%400 ==0) && year%100 != 0) ? "Leap" :"Ordinary");
return 0;
}
'C Programming' 카테고리의 다른 글
posZeroNeg2 (양수,음수,0 판단 삼항연산자) (0) | 2023.08.01 |
---|---|
passFail3.c(합격,실패 판별 삼항연산자) (0) | 2023.08.01 |
oddEven3.c(홀수,짝수 판단 삼항연산자) (1) | 2023.08.01 |
multiplyTable.c (구구단) (0) | 2023.08.01 |
absoluteValue2.c (절댓값 구하기-삼항연산자) (0) | 2023.08.01 |