Preview
Simple if statement in C language
Simple if statement in C language 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:
if(Test)
{
Block;
}
Test is conditional expression. If it is true, Block of statements gets executed. otherwise Block will not execute. Block is a set of C language statements .
Program to demonstrate simple if statement in C Language. |
#include<stdio.h> int main() { int a=10; if(a<0) printf("number is -ve"); printf("\nBye"); return 0; } |
Output |
Bye |
In the above program, a is 10.
Condition a<0 is false so only printf(“\nBye”) would be executed.