Sitemap

Write the C program take student marks as input from 0–100 and Print the results (A-E). Write a statement to handle invalid inputs ?

1 min readSep 12, 2023

--

85 -100 — A+

70 -84 — A

65 -69 — A

60 -64 — B+

55 -59 — B

50 -54 — B

45 -49 — C+

40 -44 — C

35 -39 — C

30 -34 — D+

25 -29 — D

00 -24 — E

Answer is — >>

#include<stdio.h>

int main(){

int m;

printf(“enter your mark :\n”);

scanf(“%d”,&m);

if(m>0 && m<100){

switch(m/5){

case 20 : case 19: case 18: case 17:

printf(“ A+”);

break;

case 16: case 15: case 14:

printf(“ A”);

break;

case 13:

printf(“ A-”);

break;

case 12:

Get Jashvanth Balakirushnan’s stories in your inbox

Join Medium for free to get updates from this writer.

printf(“ B+”);

break;

case 11:

printf(“ B”);

break;

case 10:

printf(“ B-”);

break;

case 9:

printf(“ c+”);

break;

case 8:

printf(“ C”);

break;

case 7:

printf(“ c-”);

break;

case 6:

printf(“ D+”);

break;

case 5:

printf(“ D”);

break;

case 4: case 3: case 2: case 1:

printf(“ E”);

break;

}

}else{

printf(“\n\n invalid marks \n”)

}

return 0;

}

--

--

Jashvanth Balakirushnan
Jashvanth Balakirushnan

Written by Jashvanth Balakirushnan

💻 Software Engineering Intern @Boffo System Labs | 🎓 Undergraduate in Software Engineering,University of Kelaniya | 🚀Passionate about Web Development & Cloud