Skip to main content

Simple Relational Operator Example Program In C++

1 min read
Share:
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.

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:

Related Tutorials

Search tutorials