Monday 25 July 2011

[chapter 4]let us c [SOLVED]



[D]Write a program which to find the grace marks for a student using switch. The user should enter the class obtained by the student and the number of subjects he has failed in.
− 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

}

click here for Answer!!!

3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. void main()
    {
    int c,s;
    printf("\nEnter the class obtained by the student and the number of subjects he has failed in");
    scanf("%d%d",&c,&s);

    switch(c)
    {
    case 1:
    if(c==1&&s<=3)
    {
    printf("\n the grace is 5 per subject");
    }
    else
    {
    printf("\n no grace");
    }
    break;
    case2:
    if(c==2&&s<=2)
    {
    printf("\n the grace is 4 per subject");
    }
    else
    {
    printf("\n no grace");
    }
    break;
    case3:
    if(c==3&&s==1)
    {
    printf("\n the grace is 5 per subject");
    }
    else
    {
    printf("\n no grace");
    }
    break;
    }
    }

    ReplyDelete