if
C uses the keyword if to implement the decision
control instruction.
if statement can’t terminate
with semicolon, but by mistake if we terminate ,compiler won’t give any error.
Syntax
if (test condition)
{
------------------------------------
------------------------------------
------------------------------------- block of statements
--------------------------------------
}
Stmt-x;
Sample if program
#include<stdio.h>
#include<conio.h>
void main()
{
int i=5;
if(i>2)
{
printf(“welcome
to IT Dept”);
printf(“welcome
to CSE Dept”);
}
if(i<=2)
printf(“welcome
to MECH Dept”);
getch();
}