Wednesday, November 21, 2018

Nested If-else

2 comments

Nested If-else

 The If condition is true so execute statement-1, other-then next condition checked else-if condition is true so execute statement-2, or so on.

 you know that if condition is true then statement execute. else if condition also like if operation perform .


            Syntax: - If (condition) {
                             Statement-1;
                              }
                             else if (condition) 
                               {
                                    Statement;
                                }
                                       :
                                       :
                             else {
                                  Statement;
                                      }  

Example: -


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#include <stdio.h> //header file section
int main() 
 {

  int x = 47, y = 25, z = 3;

   if (x > y)
    {
    if (x > z)
        {
      printf("The value x is greater than y and z ");

        }
     }

    printf("\n This is normal flow ");

   return 0;
 }

2 comments: