Simple Relational Operator Example Program In C++
On this page (8sections)
About this program
This is an example program in c operator example programs. Read the concept first: Arithmetic Operators Example in C++, then study the code and output below.
Relational Operators
- It compares two operands and depending on their relationship.
Syntax
Op1 Operator Op2
Example :
a > b
There are six relational operators. They are,
- < less than
- > greater than
- <= less than or equal to
- >= greater than or equal to
- == equal to
- != not equal to
Example of Relational Operator Program
// Header Files
#include<iostream>
#include<conio.h>
//Main Function
using namespace std;
int main ()
{
// Variable Declaration
int a = 25, b = 5;
//int a = 5, b = 25;
//int a = 5, b = 5;
cout << "Simple Relational Operator Example Program \n";
if( a>b )
cout<<"A is Big";
else if( a== b)
cout<<"A and B are Equal";
else
cout<<"B is Big";
// Wait For Output Screen
getch();
//Main Function return Statement
return 0;
}
Sample Output
Simple Relational Operator Example Program
//if a = 25, b = 5;
A is Big
//if a = 5, b = 25;
B is Big
//if a = 5, b = 5;
B is Big
Related Pages
Learn the concept first, then study the code:
- C++ Programs — Browse all C++ Programs.
- Arithmetic Operators Example in C++ — Tutorial — arithmetic, relational and logical operators.
- Simple Logical Operators Example Program In C++ — More in c operator example programs.
- Simple Assignment Operators Example Program In C++ — More in c operator example programs.