Skip to main content

Simple Relational Operator Example Program In C++

1 min read Updated June 30, 2026
Share:
On this page (9sections)

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.

Read About C++ Operators

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

Learn the concept first, then study the code:

Frequently Asked Questions

What does this C++ program do?
It is a C++ example program that demonstrates Simple Relational Operator, including the complete source code and the expected sample output.
How do I compile and run this C++ program?
Save the code in a `.cpp` file, compile it with `g++ filename.cpp -o program`, then run it with `./program` (or `program.exe` on Windows).
What concepts does this example use?
This example uses conditional logic, illustrating a common pattern in C++ programming.

Related Tutorials

Search tutorials