If Statement in C Language
If statement is a very powerful decision making statement and it is used to control the flow of execution of statements.
There are four types of if statement:
- Simple if
- If else
- Nested if
- If else if ladder
Simple if statement in C language
In simple if statement, there is only one Condition and depending upon the Condition, a particular set of statements will be executed. The syntax of simple if statement is:
Condition is comparison expression. If condition is true, only then StatementBlock will be executed. otherwise Statement-Block will not execute. Statement-Block is a set of statements of C .
|Program to demonstrate simple if|
printf(“number is -ve”);
In the above program, a is 10.
Condition a<0 is false so only printf(“\nBye”) would be executed.