C++ Program

Object:-Write A C++ Program To Comparing Integers Using If Statements, Relational Operators And Equality Operators.

#include<iostream.h> 
#include<conio.h> 
void main() 
{ 
  int number1; 
  int number2; 
  clrscr(); 
  cout << "Enter Two Integers to Compare: "; 
  cin >> number1 >> number2; 
  if ( number1 == number2 ) 
  cout << number1 << " == " << number2 << endl; 
  if ( number1 != number2 ) 
  cout << number1 << " != " << number2 << endl; 
  if ( number1 < number2 ) 
  cout << number1 << " < " << number2 << endl; 
  if ( number1 > number2 ) 
  cout << number1 <<" > " << number2 << endl; 
  if ( number1 <= number2 ) 
  cout << number1 << " <= " << number2 << endl; 
  if ( number1 >= number2 ) 
  cout << number1 << " >= " << number2 << endl; 
  getch(); 
}  

Output

Enter Two Integers to Compare: 10
20
10 !=20
10 < 20
10 <= 20

Explanation


									
									
									







You may also like: