Wednesday, May 20, 2020

Logical operators in C++

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

int main() {
  cout <<"\n----------------LOGICAL OPERATORS----------------\n";
  int x = 8;
  cout <<"\n("<<x<<" > 3 && "<<x<<" < 10 ) is "<<(x > 3 && x < 10); // returns true (1)
  cout <<"\n("<<x<<" > 3 || "<<x<<" < 10 ) is "<<(x > 3 || x < 4); // returns true (1)
  cout <<"\n (!("<<x<<" > 3 && "<<x<<" < 10 )) is "<<(!(x > 3 && x < 10)); // returns false (0)
  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...