An if statement consists of a Boolean expression followed by one or more statements.
If the boolean expression is true, the block of code inside the if statement will be executed else not.
Syntax
Syntax of if
statement in C:
1 2 3 4 5 | if (boolean expression) { /* if expression is true */ statements... ; /* Execute statements */ } |
if statement Flowchart:

Example of if statement in C Program:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #include <stdio.h> void main() { int num1, num2; num1 = 90; num2 = 50; if (num1 > num2) { printf("num1 is greater than num2"); } } |
The output of if statement in C.
num1 is greater than num2