반응형
문제
영문 대문자를 입력받아
'A'이면 “Excellent”,
'B'이면 “Good”,
'C'이면 “Usually”,
'D'이면 “Effort”,
'F'이면 “Failure”,
그 외 문자이면 “error” 라고 출력하는 프로그램을 작성하시오.
입력 예
B
출력 예
GOOD
CODE
#include<stdio.h>
int main(){
char ch;
scanf("%c",&ch);
if(ch == 'A')
printf("Excellent");
else if(ch == 'B')
printf("Good");
else if(ch == 'C')
printf("Usually");
else if(ch == 'D')
printf("Effort");
else if(ch == 'F')
printf("Failure");
else
printf("error");
}
번외로, 문제에서는 대문자 A~D까지만 사용하였으니, 처음에 대문자인지 구별하거나, 소문자인지 구별하는 방법은
https://iwantlunch.tistory.com/261
C언어 대문자를 소문자로, 소문자를 대문자로 변환하는 코드
C language에서 소문자를 대문자로, 대문자를 소문자로 변환해보려고 합니다. 소문자 -> 대문자 #include int main(){ char ch; scanf("%c",&ch); if(ch >= 'a' && ch <= 'z') ch -=32; printf("%c\n",ch..
iwantlunch.tistory.com
질문은 댓글로 받습니다. 감사합니다.
반응형
'Jungol Algorithm > Language Coder' 카테고리의 다른 글
정올 CODE 536 선택제어문 - 자가진단9 (0) | 2020.04.25 |
---|---|
정올 CODE 535 선택제어문 - 자가진단8 (0) | 2020.04.25 |
정올 CODE 533 선택제어문 - 자가진단6 (0) | 2020.04.24 |
정올 CODE 532 선택제어문 - 자가진단5 (0) | 2020.04.23 |
정올 CODE 531 선택제어문 - 자가진단4 (0) | 2020.04.20 |