Else-if:
A Multipath
decision is a chain of ifs in which the
statement associated with each else is an if.
Syntax:
if(condition-1)
stmt-1;
else if(condition-2)
stmt-2;
else
if(condition-3)
stmt-3;
………………….
else if(condition-n)
stmt-n;
else
defalut stmt;
Sample Program :
#include <stdio.h>
void main( )
{
int m1, m2, m3, m4, m5, per ;
clrscr();
scanf(“%d%d%d%d%d”,&m1,&m2,&m3,&m4,&m5);
per = ( m1+ m2 + m3 + m4+ m5 ) / 5 ;
if ( per >= 60 )
printf ( "First division" ) ;
else if ( per >= 50 )
printf ( "Second division" ) ;
else if ( per >= 40 )
printf ( "Third division" ) ;
else
printf ( "fail" ) ;
getch();
}