Nested if

Written By -

Nested if

 

Nested if statement means that you can use one if or else statement inside another if or else statement.

The nested if statement looks like this:

if(condition)
    {
        if(condition)
        {
            execute this statement;
        }
    }

Example :

                   
#include <stdio.h>
int main()
{
  int a=20,b=30;
  if (m>n) {
 printf(“a is greater than b”);
            }
  else if(a < b) {
  printf(“a is less than b”);
                   }
  else {
  printf(“a is equal to b”);
        }
  return 0;
}

Output :

   a is less than b

Report Error/ Suggestion

Related Posts:

[yuzo_views]











CopyRight © 2019

CopyRight © 2019