C++ Program To Demonstrate Comparison Operator

C++ Program To Demonstrate Comparison Operator

Write C++ Code for comparison operator

// Write C++ program to demonstrate comparison operator


#include<bits/stdc++.h>

using namespace std;

int main()
{
    int a = 10, b = 8, c = 8;

    cout << "The value of a :" << a <<endl;
    cout << "The value of b :" << b <<endl;
    cout << "The value of c :" << c <<endl;

    //Comparison operator return 1 if true, else return 0
    cout << a << " == " << b << endl ;
    cout << a <<" == " << c << endl ;
    cout << a <<" > " << b << endl ;
    cout << a << " > " << c << endl ;
    cout << a << " < " << b << endl ;
    cout << a <<" < " <<  c << endl ;
    cout << a <<" != " << c << endl ;
    cout << a  <<" != " <<  b << endl ;
    cout << a << " >= " << b << endl ;
    cout << a << " >= " << c << endl ;
    cout << a  <<" <= " << b << endl ;
    cout << a  <<" <= " << c << endl ;

    return 0;
}

Output:

The value of a :10
The value of b :8
The value of c :8

10 == 8
10 == 8
10 > 8
10 > 8
10 < 8
10 < 8
10 != 8
10 != 8
10 >= 8
10 >= 8
10 <= 8
10 <= 8