If Statement
If condition is a type of selection
control structure. It is used to make decisions. It works on a given
condition and evaluates the result if the given condition is true.
Syntax:
The general
syntax of if statement as follow:
If
(condition)
{
Statement
1;
Statement
2;
:
:
Statement
N;
}
Example:
There is an example to understand
if statement.
#include<conio.h>
#include<iostrem.h>
void main()
{
Int
marks=0;
cout
<< “ Enter Marks: ” ;
cin>>
marks;
if( marks > 40 )
cout << “Congratulation, You
have Passed” ;
getch();
}
But there
is a problem with if statement it
evaluates only if the given condition is true otherwise no result will
displayed.