·  C++ – Syntax – Operators – Comparison

 

- Info:

  - This tutorial shows how to use Comparison Operators in C++.: == != < <= > >= instanceof.

 

- Example:

  - Create C++ Console Application Test.cpp.

 

    Test.cpp

    #include <stdio.h>

    #include <iostream>

    using namespace std;

    

    int main() {

   

      char left  = 65;

      long right = 70;

   

      if (left == right) { printf("Left    equals            right.\n"); }

      if (left != right) { printf("Left is different from    right.\n"); }

      if (left <  right) { printf("Left is smaller then      right.\n"); }

      if (left <= right) { printf("Left is smaller or equals right.\n"); }

      if (left >  right) { printf("Left is greater then      right.\n"); }

      if (left >= right) { printf("Left is greater or equals right.\n"); }

   

      return 1;

   

    }