## Tuesday, July 04, 2006

### [1/3] Calculation of Marks using if-else

This program demonstrates the use of the if-else statement to write the following program.
The program can also be materialized by using either logical operators or the elseif statement.

The marks obtained by a student in 5 different subjects are input through the keyboard.

The student gets a division as per the following rules:

Percentage above or equal to 60 - First Division
Percentage between 50 and 59 -- Second Division
Percentage between 40 and 49 --- Third Division
Percentage less than 40 ---- Fail

Write a program to calculate the division obtained by the student.

#include<stdio.h>

main()
{

int m1, m2, m3, m4, m5, per;
printf ("Enter marks in five subjects:");

scanf ("%d %d %d %d %d", &m1, &m2, &m3, &m4, &m5);

per=(m1+m2+m3+m4+m5)/5;

if (per>=60)
printf ("First Division\n");

else
{
if (per>=50)
printf ("Second Division\n");

else
{
if (per>=40)
printf ("Third Division\n");

else
printf ("Fail\n");
}
}

}

The file can also be found at: