본문 바로가기

프로그래밍 언어들/C 문제풀이

C언어 문제 - 점수를 입력받아 학점 출력하기 (questions in C)

C언어 문제 - (questions in C)

- 0~100 사이의 점수를 입력받아 90~100 사이면 A, 80~89 사이면 B, 70~79 사이면 C,

60~69 사이면 D, 나머지는 F를 출력하라.

 

#include <stdio.h>

int main (void)
{
    int score;

    scanf("%d", &score);

    if( score >= 90 && score <= 100)
    {
        printf("A\n");
    }
    else if( score >= 80 && score <= 89)
    {
        printf("B\n");
    }
    else if( score >= 70 && score <= 79)
    {
        printf("C\n");
    }
    else if( score >= 60 && score <= 69)
    {
        printf("D\n");
    }
    else
    {
        printf("F\n");
    }
}