Thursday, 10 March 2016

C Program For Find A Grade Of Given Marks Using Switch Case

#include
#include

int main()
{
//Ghanendra Yadav
   int marks;
 
   printf("Enter your marks between 0 to 100\n");
   scanf("%d", &marks);
 
   switch(marks/10)
   {
       case 10 :
       case 9 :
           /* Marks between 90-100 */
           printf("Your Grade : A\n" );
           break;
       case 8 :
       case 7 :
           /* Marks between 70-89 */
           printf("Your Grade : B\n" );
           break;
       case 6 :
           /* Marks between 60-69 */
           printf("Your Grade : C\n" );
           break;
       case 5 :
       case 4 :
           /* Marks between 40-59 */
           printf("Your Grade : D\n" );
           break;
       default :
           /* Marks less than 40 */
           printf("You failed\n" );
   }

   getch();
   return 0;
}

Output:-


4 comments:
Write comments
  1. whithout header file how can you your program work successfully

    ReplyDelete
  2. Latest IDE's does not need headers
    Like codeblocks
    Che k it

    ReplyDelete

Recommended Posts × +