C – if statement

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:

 if (boolean expression)
  {
   /* if expression is true */
   statements... ; /* Execute statements */
  }

if statement Flowchart:

if statement

Example of if statement in C Program:

#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