in else if condition we can put more than 2 possiblities.
SYNTAX:
if(condition)
{
statements;
}
else if(condition)
{
statements;
}
else if(condition)
{
statements;
}
.
.
.
.
else
{
statements;
}
EXAMPLE FOR ELSE IF:
#include<stdio.h>
#include<conio.h>
main()
{
int a;
clrscr();
printf("Enter Number: ");
scanf("%d",&a);
if(a==1)
{
printf("\nYou have entered 1");
}
else if(a==2)
{
printf("\nYou have entered 2");
}
else if(a==3)
{
printf("\nYou have entered 3");
}
else
{
printf("\nYou have Entered less than 1 or greater than 3");
}
getch();
}
#include<conio.h>
main()
{
int a;
clrscr();
printf("Enter Number: ");
scanf("%d",&a);
if(a==1)
{
printf("\nYou have entered 1");
}
else if(a==2)
{
printf("\nYou have entered 2");
}
else if(a==3)
{
printf("\nYou have entered 3");
}
else
{
printf("\nYou have Entered less than 1 or greater than 3");
}
getch();
}