Write a program that accepts a letter grade as input and outputs the teacher's remarks. Use only switch, do not use any if's. Example: If 'A' or 'a', then "Excellent job!". If 'F' or 'f', then "You failed. Please study more next time."
#include <stdio.h>
void main(){
char letterGrade;
printf("Enter letter grade: ");
scanf("%c",&letterGrade);
switch(letterGrade){
case 'a':
case 'A':
printf("Excellent job!\n");
break;
case 'f':
case 'F':
printf("You failed. Please study more next time!\n");
break;
default:
printf("Invalid input.\n");
break;
}
scanf("%d",&letterGrade);
}
Comments
Leave a comment