[3/3]Calculation of Marks using Logical Operators.

The most efficient of the three programs. Solves all the problems arising out of the usage of if else and else if statements.


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");

if ((per>=50) && (per<60))

printf ("Second Division");

if ((per>=40) && (per<50))

printf ("Third Division");

if (per<40)

printf ("Fail");

}



The file can be found at:
Download File

Comments

Popular posts from this blog

C Program - Calculation of Area and Circumference of a Circle using Pointers

Matchstick Game using C Programming

Generation of Fibonacci Sequence using Recursion.