This C Program reads grade & displays the equivalent description. If grade is S, it prints super, if grade is A, it prints very good, if grade is B, it prints fair, if grade is Y, it prints absent, if grade is F, it prints fails.
Here is source code of the C program to read a grade & display the equivalent description. The C program is successfully compiled and run on a Linux system. The program output is also shown below.
* C Program to accept a grade and declare the equivalent description
* if code is S, then print SUPER
* if code is A, then print VERY GOOD
* if code is B, then print FAIR
* if code is Y, then print ABSENT
* if code is F, then print FAILS
printf("Enter the grade \n");
/* lower case letter to upper case */
grade = toupper(grade);
strcpy(remark, " SUPER");
strcpy(remark, " VERY GOOD");
strcpy(remark, " FAIR");
strcpy(remark, " ABSENT");
strcpy(remark, " FAILS");
strcpy(remark, "ERROR IN GRADE \n");
printf("RESULT : %s\n", remark);
$ cc pgm78.c $ a.out Enter the grade s RESULT : SUPER $ a.out Enter the grade a RESULT : VERY GOOD $ a.out Enter the grade b RESULT : FAIR $ a.out Enter the grade y RESULT : ABSENT $ a.out Enter the grade f RESULT : FAILS
If you wish to look at other example programs on Simple C Programs, go to Simple C Programs. If you wish to look at programming examples on all topics of C, go to C Programming Examples.