Write a program to find grace marks for a student using switch. The user should enter the class obtained by student and the number of subjects he has failed in uses the follow logic.
 if the student gets first class and the number of subjects he failed in is greater than 3 then he does not get any grace. If the number of subjects he failed in is less than or equal to 3 then the grace is of 5 marks per subject.
 If the student gets second class and the number of subjects he failed in is greater than 2, then he does not get any grace. If the number of subjects he failed in is less than or equal to 2, then the grace is of 4 marks per subject.
 If the student gets third class and the number of subjects he failed in is greater than 1, then he does not get any grace. If the number of subjects he failed in is equal to 1 then the grace is of 5 marks per subject.

Write a program to find grace marks for a student using switch. The user should enter the class obtained by student and the number of subjects he has failed in uses the follow logic.
 if the student gets first class and the number of subjects he failed in is greater than 3 then he does not get any grace. If the number of subjects he failed in is less than or equal to 3 then the grace is of 5 marks per subject.
 If the student gets second class and the number of subjects he failed in is greater than 2, then he does not get any grace. If the number of subjects he failed in is less than or equal to 2, then the grace is of 4 marks per subject.
 If the student gets third class and the number of subjects he failed in is greater than 1, then he does not get any grace. If the number of subjects he failed in is equal to 1 then the grace is of 5 marks per subject.

#include<stdio.h>
#include<conio.h>
void main()
{

    int class, nos_fail, grace;
    printf("Enter class obtained by student and number of subjects he failed in ");
    scanf("%d%d",&class,&nos_fail);
    switch(class)
    {
        case 1:
            switch(nos_fail)
            {
                case 1:
                case 2:
                case 3:
                    grace=5;
                    break;

                default:
                    grace=0;
                    break;
            }
            break;

        case 2:
            switch(nos_fail)
            {
                case 1:
                case 2:
                    grace=4;
                    break;

                default:
                    grace=0;
                    break;
            }
            break;

        case 3:
            switch(nos_fail)
            {
                case 1:
                    grace=5;
                    break;

                default:
                    grace=0;
                    break;
            }
            break;
    }
    printf("\nStudent will get %d grace marks per subject",grace);
    getch();
}

Edited 1 Year Ago by happygeek: don't create multiple accounts and post same thing multiple times

This article has been dead for over six months. Start a new discussion instead.