BCA

C LAB :PART A

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7 PROGRAM 8 PROGRAM 9 PROGRAM 10

C LAB : PART B

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7 PROGRAM 8 PROGRAM 9 PROGRAM 10

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

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



#include < stdio.h>
#include < stdlib.h>
void main()
{
    long int m1, m2, m3, m4, m5, m6;
    long int percent;

    printf("Enter the marks for 6 subjects\n");
    scanf("%ld %ld %ld %ld %ld %ld", &m1, &m2, &m3, &m4, &m5, &m6);

    percent = ((m1 + m2 + m3 + m4 + m5 + m6) * 100 / 600);
    printf("Percentage : %ld\n", percent);

    if(percent >90)
        printf("S grade\n");
       
    else if(percent >70)
        printf("A grade\n");
        
    else if(percent >50)
        printf("B grade\n");
        
    else if(percent >40)
        printf("C grade\n");
        
    else if(percent >30)
        printf("D grade\n");
  
    default:
        printf("Invalid input");
        exit(0);
    }
}