- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Relational and comparison operators in C++
In C Programming, the values keep in 2 variables can be compared using following operators and relation between them will be determined. These operators are called relational operators. Various C++ relational operators available are-
Operators | Description |
---|---|
> | Greater than |
>= | Greater than or equal to |
== | Is equal to |
!= | Is not equal to |
<= | Less than or equal to |
< | Less than |
You can use these operators for checking the relationship between the operands. These operators are mostly used in conditional statements and loops to find a relation between 2 operands and act accordingly. For example,
Example
#include<iostream> using namespace std; int main() { int a = 3, b = 2; if(a < b) { cout<< a << " is less than " << b; } else if(a > b) { cout<< a << " is greater than " << b; } else if(a == b){ cout << a << " is equal to " << b; } return 0; }
Output
This will give the output −
3 is greater than 2
Advertisements