C++ Program to execute if statement without any expression


In this program, You will learn how to execute if statement without any expression in C++.


1 or int = True

0 = False

if( a ){ }


Example: How to execute if statement without any expression in C++

Run it Now
#include<iostream>
using namespace std;

int main() {

    int a;

    cout << "Enter a Number :";
    cin >> a;

    if (a) {
        cout << "\nWelcome";
    } else {
        cout << "\nGood Bye";
    }

    return 0;
}

Output:

Enter a Number :1
Welcome