TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

C++

C++ Relational Operators

Overview

In this tutorial, we will learn about C++ relational operators with a sample program. Relational operators are used to evaluate conditions in the code.

C++ Relational Operators

 

Condition Operator Sample Example
Greater then > x > y
Less than < x < y
Greater than or Equal to >= x >= y
Less than or Equal to <= x <= y
Equal To == x == y
Not Equal To != x != y

 

Sample C ++ Program

/************************************
* C++ Relational Operators
* Filename: relational.cpp
* C++ Relational Operators Demo
* program.
* C++ Tutorials - www.TestingDocs.com
**************************************/
#include
using namespace std;
int main()
{
 //Declare two variables
 int x=20,y=5;
 // Print Statements
 bool result;
 cout << "1 = True | 0 = False" << endl; result = (x > y);
 cout << "Is x Greater Than y ? = " << result << endl;
 result = (x < y);
 cout << "Is x Less Than y ? = " << result << endl; result = (x >= y);
 cout << "Is x Greater Than Equal To y ? = " << result << endl;
 result = (x <= y);
 cout << "Is x Less Than Equal To y ? = " << result << endl;
 result = (x == y);
 cout << "Is x Equal To y ? = " << result << endl;
 result = (x != y);
 cout << "Is x Not Equal To y ? = " << result << endl;
 return 0;
} // end main

C++ Relational Operators

Output

1 = True | 0 = False
Is x Greater Than y ? = 1
Is x Less Than y ? = 0
Is x Greater Than Equal To y ? = 1
Is x Less Than Equal To y ? = 0
Is x Equal To y ? = 0
Is x Not Equal To y ? = 1

 

That’s it.

—

C++ Tutorials

C++ Tutorials on this website:

https://www.testingdocs.com/c-coding-tutorials/

For more information on the current ISO C++ standard

https://isocpp.org/std/the-standard

Related Posts

g not found OpenSuse

C++ /

Install GCC C++ Compiler on OpenSuse

sum of digits c program

C++ /

Sum of Digits of a Number C++ Program

C++ Hello World Program

C++ /

C++ Hello World Program

C++ /

Object-Oriented Programming Language Examples

C++ /

Object-Oriented Programming Features

‹ C++ Arithmetic Operators› C++ Command Line Arguments

Recent Posts

  • MS Access Data Types
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version