- if statement is very powerful decision making statement.
- C uses if statement to execute a specific set of statements when the given logical condition is true.
- Here is a syntax of if statement as follows:
- Statements present inside if block are executed only when the condition is true. In case the condition is false the compiler skips the statements within if block. Here is a diagram that represents the concept of if statement more clearly:
- Here is an example of if statement:
printf(“n Enter the value of a and b:”);
printf(“value of a and b are equal”);
The output of the above program is as follows:
Enter the value of a and b: 4
Value of a and b are equal