C uses the keyword
if-else to implement the decision control instruction.
Syntax
if(test condition-1)
{
if(test condition-2)
{
block of stmt-1;
}
else
{
block of stmt-2;
}
}
else
{
block
of stmt-3;
}
Stmt-x;
Note: braces are mandatory when, corresponding to if or else
statement, multiple steps are to be executed.
Sample program
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
printf(“\nenter any
number\n”);
scanf(“%d”,&n);
if(n%2==0)
{
printf(“%d is
even number”,n);
}
else
{
printf(“%d is odd number”, n);
}
getch();
}