Advertisement



< Prev
Next >



C - Nested If Else Statement




In nested if-else decision making statement of C language, an if-else statement is nested inside an if statement, hence this control structure is named nested if-else.




Working of nested if-else


  • If the condition of outer if statement is false then the statement connected to its else(optionally declared) is executed and the nested if-else is not executed at all.

  • The statement connected to the if of the nested if-else is only executed when -: If condition of this nested if is false then the statement with its connected else is executed.




    Advertisement




    Nested if-else example


    /* nested if-else example */
    
    
    #include<stdio.h>
    int main()
    {
    
    if(99<100)
    {
    	if(99<98)
    	 	printf("99 is less than 100 & 99 is also less than 101");
    	else
    		printf("99 is less than 100 but 99 is not less than 98");
    }
    else 
    	printf("99 is not less than 100");
    	
    return 0;
    }
    


    Output


    99 is less than 100 & 99 is also less than 101




    Please share this article -





    < Prev
    Next >
    < Nested If Statement
    For Loop>



    Advertisement

    Please Subscribe

    Please subscribe to our social media channels for daily updates.


    Decodejava Facebook Page  DecodeJava Twitter Page Decodejava Google+ Page




    Advertisement

    Notifications



    Please check our latest addition

    PYTHON and DJANGO


    Advertisement