Search This Blog

Thursday, 31 October 2024

5. Write a C Program to read percentage of marks and to display appropriate grade (using switch case)

 /*5. Write a C Program to read percentage of marks and to display appropriate grade (using switch case) */

#include<stdio.h>

void  main()

{

     int percent;

     clrscr();

     printf("Enter Marks in Percentage:");

     scanf("%d",&percent);

     switch(percent/10)

     {

           case 10:

           case  9:

           case  8:

           case  7:  printf("Distinction! Or Grade-A\n");

                     break;

           case  6:  printf("First Class! Or Grade-B\n");

                     break;

           case 5:   printf("Second Class! Or Grade-C\n");

                     break;

           case 4:   printf("Pass! Or Grade-P\n");

                     break;

          default:   printf("Fail! Or Grade-F\n"); break; 

     

     getch();

}

 

 

No comments :

Post a Comment

FREE Hit Counters