Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

RafaTorresDeveloper: First IF ELSE C++

#include <iostream>

using namespace std;

int main()
{
    // This is a comment
    // We can write what we want there to help
    // Us communicate things to other programmers
    
    // Let's setup some data here to use for our program
    // int is an integer data type like -4, -2, -1, 0, 1, 2, 3 no decimals
    // We can read up on other data types here: 
    // https://www.tutorialspoint.com/cplusplus/cpp_data_types.htm
    
    // Change the value 7 to other integers greater and smaller than 6 to change your output
    int integerData = 4;
    
    if(integerData >= 6)
    {
        cout << "My integerData " + std::to_string(integerData) + " is greater than or equal to 6" << endl;
    }
    else
    {
        cout << "My integerData " + std::to_string(integerData) + " is less than 6" << endl;        
    }
    
    if(integerData = integerData)
    {
        
        if(integerData >= 6)
        {
            cout << "In Nested If Else: My integerData " + std::to_string(integerData) + " is greater than or equal to 6" << endl;
        }
        else
        {
            cout << "In Nested If Else: My integerData " + std::to_string(integerData) + " is less than 6" << endl;        
        }
    }
   
   return 0;
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.