Notice
Recent Posts
Recent Comments
Creative Code
scoreGrade3.c(점수별 학점분류 switch문) 본문
#include <stdio.h>
int main(void)
{
int score;
printf("점수 입력: \n");
scanf("%d",&score);
char grade;
switch(score/10) {
case 10: // case 9와 case 10의 경우가 같을 땐 생략할 수 있다.
case 9 :
grade = 'A';
break;
case 8 :
grade = 'B';
break;
case 7 :
grade = 'C';
break;
case 6 :
grade = 'D';
break;
default : //나머지
grade = 'F';
//default문은 break문이 따로 필요 없다.
}
printf("score : %d ---- grade :%c\n",score,grade);
return 0;
}
'C Programming' 카테고리의 다른 글
star2.c(역계단모양 별 출력) (0) | 2023.08.01 |
---|---|
star.c(계단모양 별 출력) (0) | 2023.08.01 |
pyramid.c(별 피라미드모양으로 출력) (0) | 2023.08.01 |
printOne2Ten2.c (1에서 10까지 출력) (0) | 2023.08.01 |
printOne2Ten.c(1부터 10까지 출력) (0) | 2023.08.01 |