Combine the if and else keywords to check for multiple alternatives - C++ Statement

C++ examples for Statement:if

Description

Combine the if and else keywords to check for multiple alternatives

Demo Code

#include <iostream> 

using namespace std; 

int main() /*from   w  ww .  j a  v  a2 s  .  c  o  m*/
{ 
    int i; 

    cout << "Type any number: "; 
    cin >> i; 

    if (i > 10) 
    { 
        cout << "It's greater than 10." << endl; 
    } 
    else if (i == 10) 
    { 
        cout << "It's equal to 10" << endl; 
    } 
    else 
    { 
        cout << "It's less than 10." << endl; 
    } 

    return 0; 
}

Result


Related Tutorials