#include <stdio.h>
int main() {
/* 연산자 우선순위
1. 괄호 ()
2. 단항 연산자 ! ++ --
3. 산술 연산자 * / % -> + -
4. 비교 연산자 > < >= <= == !=
5. 논리 연산자 && -> ||
6. 대입 연산자 = += -=
*/
int a = 5, b = 10, c = 15;
printf("----문제----\n");
// 문제 : 아래 식에서 연산 순서를 적으시오
printf("%d\n", a + b > c && c == 15);
// 1 2 4 3
printf("%d\n", a * b + c > b || a == 5);
// 1 2 3 5 4
printf("%d\n", !(a + b <= c) && b != 10);
// 3 1 2 5 4
// 삼항 연산자 : 한 줄로 조건문을 만들기
// 조건식 ? 참일때 값 : 거짓일 때 값
printf("%s\n", 5 > 10 ? "참" : "거짓");
int score = 100;
printf("%s\n", score >= 60 ? "합격" : "불합격");
int x = 5, y = 9;
int max = x > y ? x : y;
printf("더 큰 값은 %d\n", max);
printf("----숙제----\n");
int d = 7, e = 12;
// 문제 : 아래 식에서 연산 순서를 적으시오
printf("%d\n", 5 * d + e > 20 && 30 == e);
// 1 2 3 5 4
printf("%d\n", (d + e) * 2 <= 50 || 40 - e == d);
// 1 2 4 6 3 5
printf("%d\n", !(d + e > 10 || d * e < 50) && e != 15);
// 6 2 3 5 1 4 8 7
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: