Nested If Else In C Programming With Example

Explain What Is Nested If Else Statement With Example In C Programming
\\ If you have any query or questions on my post, then please comment below //

What Is Nested If Else Statement: 
In  our previous page you learn if statement with an example and else statement with an example. In else statement you know, We are writing our program in 2 statements. But if we are having more than 2 statements, Then we can't write programs in else statement. So for writing more than one statement in c program or use if and else statement inside the if statement, c evaluated Nested If Else Statement.

Nested if else statement provides us the facility to write more than one statement in a single program. 

Syntax Of Nested If Else Statement: 
 ----------------------------------------------------------------------------------------------
if(test_condition1)
{
   if(test_condition2)
    {
           ----------------------
           ----------------------  // Statements1 Or True Block;

    }
    else
    {
           ----------------------
           ----------------------  // Statements2 Or False Block;

    }
}
else {
         -------------------------
         ------------------------- // Statement 3 or false block code for test_condition1.
       }
---------------------------------------------------------------------------------------
The above syntax execution goes as follows: if test condition 1 is true than test condition 2 is evaluated. If it is true then the statement 1 is executed. If the test condition 2 is false, statement 2 is executed. And if test condition 1 is false then statement 3 is executed.

Another way of writing Nested If Else Statement:
Nested If Else Statement Syntax: 
----------------------------------------------------------------------------------
   if(test_condition1)
      {
        if(test_condition2)
             {
               ------------------ // Statement 1 Or True Block Code.
             }
        else
             {
                 ---------------- // Statement 2 Or False Block Code.
             } 
       }
   else
    {
       if(test_condition3)
             {
               ------------------ // Statement 3 Or True Block Code.
             }
        else
             {
                 ---------------- // Statement 4 Or False Block Code.
             } 
     } 
--------------------------------------------------------------------------------------

The above syntax execution goes as follows: if test condition 1 is true than test condition 2 is checked. If it is true then the statement 1 is executed. If the test condition 2 is false, statement 2 is executed. And if test condition 1 is false then statement 3 is checked. If it is true statement 3 is executed, otherwise statement 4 is executed.

If you have any query on above program, then please comment below. Ask your question with us.


Click Here To Know How To Download Above Video Tutorials Or YouTube Videos Free


 Enter Your Email Id To Get Our Programming, Web Development, Video Tutorial, Job Updates In Mail :

Labels: