/******************************************************************************
grader - an example of a switch statement
try removing the break statements and see what happens
*******************************************************************************/
#include <stdio.h>
int main ()
{
char student_grade = 'B';
switch (student_grade)
{
case 'A':
printf ("Your grade was %c: excellent!\n",student_grade);
break; // prevents fall-through to default
case 'B' :
printf("Your grade was %c: very good!\n",student_grade);
break;
case 'C' :
printf("Your grade was %c: good!\n",student_grade);
break;
case 'D' :
printf("Your grade was %c: satisfactory!\n",student_grade);
break;
case 'E' :
printf("Your grade was %c: needs work!\n",student_grade);
break;
case 'F' :
printf("Your grade was %c: sorry you failed!\n",student_grade);
break;
default:
printf("Error! Grade %c is invalid\n",student_grade);
}
return 0;
}