How if in C works?

Working of if Statement in C

The working of the if statement in C is as follows:

  1. STEP 1: When the program control comes to the if statement, the test expression is evaluated.
  2. STEP 2A: If the condition is true, the statements inside the if block are executed.
  3. STEP 2B: If the expression is false, the statements inside the if body are not executed.
  4. STEP 3: Program control moves out of the if block and the code after the if block is executed.

C – if Statement

The if in C is the most simple decision-making statement. It consists of the test condition and if block or body. If the given condition is true only then the if block will be executed.

Similar Reads

What is if in C?

The if in C is a decision-making statement that is used to execute a block of code based on the value of the given expression. It is one of the core concepts of C programming and is used to include conditional code in our program....

Syntax of if Statement in C

if(condition) { // if body // Statements to execute if condition is true }...

How to use if statement in C?

The following examples demonstrate how to use the if statement in C:...

How if in C works?

...

Flowchart of if in C

Working of if Statement in C...

Examples of if Statements in C

Flow Diagram of if Statement in C...

Advantages of if Statement

Example 1: C Program to check whether the number is even or odd....

Disadvantages of if Statement

...

Conclusion

...

FAQs on if in C

Following are the main advantages of the if statement in C:...