Notice
Recent Posts
Recent Comments
Creative Code
oddEven3.c(홀수,짝수 판단 삼항연산자) 본문
#include <stdio.h>
// 홀수인지 짝수인지 판별(삼항연산자)
int main(void)
{
int num;
scanf("%d",&num);
//int isOdd = (num%2 == 1);
//int isEven = (num%2 == 0);
/*
if (num%2 == 1){
printf("%d is a odd\n", num);
} else {
printf("%d is a even\n", num);
}
*/
printf("%d is a %s \n",num,(num%2) ? "odd":"even");
return 0;
}
'C Programming' 카테고리의 다른 글
passFail3.c(합격,실패 판별 삼항연산자) (0) | 2023.08.01 |
---|---|
ordinaryLeap3.c(윤년,평년 판별 삼항연산자) (0) | 2023.08.01 |
multiplyTable.c (구구단) (0) | 2023.08.01 |
absoluteValue2.c (절댓값 구하기-삼항연산자) (0) | 2023.08.01 |
procScore.c (배열 성적평균구하기) (0) | 2023.08.01 |