C++ if statement Combine if and else to check multiple alternatives

Description

C++ if statement Combine if and else to check multiple alternatives

#include <iostream> 

using namespace std; 

int main() /*from   w w  w.  j ava2s.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; 
}



PreviousNext

Related