Code
/*
* -----------------------------------------------------------
* Logic Building with Computer Programming (CSU1128P)
* Instructor: Abdullahi Adem | Author: Divya Mohan
*
* This code is a part of the educational initiative by dmj.one
* with aim of empowering and inspiring learners in the field of
* Computer Science and Engineering through the respective courses.
*
* (c) 2022, Divya Mohan for dmj.one. All rights reserved.
* -----------------------------------------------------------
*/
#include <stdio.h>
int main()
{
int d, m, j, o, n, e;
printf(" Enter numbers of Chemistry, Biology, Physics, Maths, English respectively: (Example: 88 65 95 78 83) : ");
scanf("%d %d %d %d %d", &d, &m, &j, &o, &n);
e = d + m + j + o + n;
float ave = e / 5;
if ((int)ave < 100)
{
switch ((int)ave)
{
case 90 ... 100:
printf("Congratulations! You are awarded grade O as ");
break;
case 80 ... 89:
printf("Congratulations! You are awarded grade A.");
break;
case 70 ... 79:
printf("Congratulations! You are awarded grade B.");
break;
case 60 ... 69:
printf("Congratulations! You are awarded grade C.");
break;
default:
printf("You are awarded grade F. Better Luck Next Time.");
break;
}
char per = "%";
printf("You got %.2f%c", ave, per);
return 0;
}
Output
Enter numbers of Chemistry, Biology, Physics, Maths, English respectively: (Example: 88 65 95 78 83) :99 98 98 94 90
You got 96.00% and Congratulations! You are awarded grade O.