## C Programming

### Calculate the grace marks

#### Objective

Write a program to enter the class (first, second, third) obtained by a student and subjects he failed. Then calculate the grace marks as per the following rules...

1. If a student obtains first-class and subjects he failed is between 1 to 3, then 5 marks per subject grace are allowed otherwise no grace marks allowed.
2. If a student obtains second class and subjects he failed is between 1 to 2, then 4 marks per subject grace are allowed otherwise no grace marks allowed.
3. If a student obtains third class and subjects he failed is 1, then 5 marks per subject grace are allowed otherwise no grace marks allowed.

#### Program

```#include "stdio.h"

int main() {
int cls,subjects;

printf("Enter the class,say(1,2,3): ");
scanf("%d",&cls);
printf("Enter the subjects failed: ");
scanf("%d",&subjects);

switch(cls) {
case 1:
if(subjects >=1 && subjects <= 3) {
printf("%d grace mark per subject, total grace marks = %d\n",5,5 * subjects);
}else {
printf("No grace marks");
}
break;
case 2:
if(subjects >=1 && subjects <= 2) {
printf("%d grace mark per subject, total grace marks = %d\n",4,4 * subjects);
}else {
printf("No grace marks");
}
break;
case 3:
if(subjects ==1) {
printf("%d grace mark per subject, total grace marks = %d\n",5,5 * subjects);
}else {
printf("No grace marks");
}
break;
default:
printf("Invalid class");
}
}
```

#### Output

```Enter the class,say(1,2,3): 1
Enter the subjects failed: 3
5 grace mark per subject, total grace marks = 15

Enter the class,say(1,2,3): 2
Enter the subjects failed: 3
No grace marks
```