#include <stdio.h>

int main() {
     //조건문 if 
     /* if문
     if (조건) {
          조건이 참일 때 실행할 코드;
     } */
     int n1 = 5;
     if (n1 > 0) {
          printf("n1이 0보다 크다\n");
     }

     /* if - else문
     if (조건) {
          조건이 참일 때 실행할 코드;
     } else {
          조건이 거짓일 때 실행할 코드;
     } */
     int n2 = 123;
     if (n2 % 2 == 0) {
          printf("짝수\n");
     } else {
          printf("홀수\n");
     }

     /* if -else if - else문
     if (조건1) {
          코드1;
     } else if (조건2) {
          코드2;
     } else if (조건3) {
          코드3;
     } else {
          위의 조건이 모두 거짓일 때 실행할 코드;
     } */
     int score = 85;
     // scanf("%d", &score);
     
     if (score >= 90) printf("A\n");
     else if (score >= 80) printf("B\n");
     else if (score >= 70) printf("C\n");
     else printf("F\n");
     
     int age = 10;
     if (age >= 8 && age <= 13) {
         printf("초등학생");
     } else if (age >= 14 && age <= 16) {
         printf("중학생");
     } else if (age >= 17 && age <= 19) {
         printf("고등학생");
     } else if (age >= 20){
          printf("성인");
     }
     printf("\n");

     /* switch문 
     switch (조건) {
     case 값1:
          실행할 코드1;
          break;
     case 값2:
          실행할 코드2;
          break;
     default:
          어떤 case도 해당하지 않을 때 기본 코드;
          break;
     }*/

     int menu;
     scanf("%d", &menu);
     switch (menu) {
     case 1:
          printf("아메리카노\n");
          break;
     case 2:
          printf("딸기 라떼\n");
          break;
     case 3:
          printf("초코 라떼\n");
          break;
     default:
          printf("다시 선택하세요\n");
     }
     
     char c;
     scanf(" %c", &c);
     
     switch (c) {
     case '+':
     case '-':
     case '*':
     case '/':
          printf("연산자입니다\n");
          break;
     default:
          printf("연산 기호가 아닙니다\n");
     }


     return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: