본문 바로가기
과제/C언어

프로그래밍 실습 과제 <입력 받는 점수(학점) 문제>_C언어

by 잠모뺨 2022. 9. 20.

#include <stdio.h>

 

int main()

{

int score; // 점수를 저장할 변수

char grade; // 학점에 해당하는 문자 1개를 저장할 변수

 

printf("점수를 입력하시오 : ");

scanf_s("%d", &score);

 

if (score >= 90)

grade = 'A';

else if (score >= 80)

grade = 'B';

else if (score >= 70)

grade = 'C';

else if (score >= 60)

grade = 'D';

else

grade = 'F';

 

printf("학점 : %c\n", grade);

 

return 0;

}

 

 

댓글