C

[C] 027 조건 연산자

qkrwngus 2021. 1. 20. 20:52

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 :