Desc :
조건식 ? 조건식이 참인 경우 수행 : 조건식이 거짓인 경우 수행
중복하여 쓸 수도 있음
Source Code :
#include <stdio.h>
void main()
{
int x = 1;
int y = 2;
int max;
max = x > y ? x : y > 5 ? y: x+y;
printf("max = %d\n", max);
}
Result :
'C' 카테고리의 다른 글
[C] 029 비트 연산자 (1) | 2021.01.20 |
---|---|
[C] 028 쉼표 연산자 (1) | 2021.01.20 |
[C] 026 논리 연산자 (1) | 2021.01.20 |
[C] 025 관계연산자 (1) | 2021.01.19 |
[C] 024 증감 연산자 (1) | 2021.01.19 |