Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

c++ nested if else example

// C++ program to illustrate nested-if statement
#include <iostream>
using namespace std;
 
int main()
{
    int i = 10;
 
    if (i == 10)
    {
        // First if statement
        if (i < 15)
           cout<<"i is smaller than 15
";
 
        // Nested - if statement
        // Will only be executed if statement above
        // is true
        if (i < 12)
            cout<<"i is smaller than 12 too
";
        else
            cout<<"i is greater than 15";
    }
 
    return 0;
}
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #nested
ADD COMMENT
Topic
Name
6+4 =