C Programming language

adplus-dvertising
C Program example: Using nested if else statement
Previous Home Next
To calculate student's status

In this program m1, m2, m3, m4, m5 and per are the variable of integer type. And we are using here the concept of nested if which means if inside if.

/**  To Calculate Student's Status  **/

#include <stdio.h>
#include <conio.h>
main()
{
	int m1,m2,m3,m4,m5,per;
	clrscr();
	printf ("Enter marks in five subjects");
	scanf ("%d %d %d %d %d" , &m1,&m2,&m3,&m4,&m5);
	per=(m1++m2+m3+m4+m5)/500*100;
	if(per>=60)
		printf ("First Division");
	else
	{
		if(per>=50)
			printf ("Second Division");
		else
		{
			if(per>=40)
				printf ("Third Division");
			else
				printf ("Fail");
		}
	}
}
Output:

Enter marks in 5 subjects

75,65,73,48,80

First Division

Previous Home Next