Wednesday, May 20, 2020

Comparision operators in C++

  • Program :
#include <iostream>
using namespace std;

int main() {
  cout <<"\n----------------COMPARISON OPERATORS----------------\n";
  int x = 10;
  int y = 13;
  cout <<"\n"<<x<<" == "<<y<< " is "<<(x == y); // returns 0 (false)
  cout <<"\n"<<x<<" != "<<y<< " is "<<(x != y); // returns 1 (true)
  cout <<"\n"<<x<<" > "<<y<< " is "<<(x > y); // returns 1 (true)
  cout <<"\n"<<x<<" < "<<y<< " is "<<(x < y); // returns 0 (false)
  cout <<"\n"<<x<<" >= "<<y<<" is "<<(x >= y); // returns 1 (true)
  cout <<"\n"<<x<<" <= "<<y<<" is "<<(x <= y); // returns 0 (false)
  return 0;
}

  • Output :

No comments:

Post a Comment

Function Overloading in C++

https://monitechvenkat1620.blogspot.com Program : #include <iostream> using namespace std; int c(int x, int y) {   return...