C++ Exercises: Compare two numbers
82. Compare Two Numbers
Write a program in C++ to compare two numbers.
Sample Solution:-
C++ Code :
Sample Output:
Compare the first number with second number numbers: --------------------------------------------------------- Input the first integer: 25 Input the second integer: 15 25 != 15 25 > 15 25 >= 15
Flowchart:

For more Practice: Solve these Related Problems:
- Write a C++ program to compare two integers and output whether the first is greater, less than, or equal to the second.
- Write a C++ program that reads two numbers and prints all relational operators’ results (==, !=, >, <, >=, <=).
- Write a C++ program to compare two input numbers and display a detailed message indicating their relation.
- Write a C++ program that uses conditional operators to compare two integers and outputs the comparison result in a formatted statement.
C++ Code Editor:
Contribute your code and comments through Disqus.
Previous: Write a program in C++ to convert a hexadecimal number to octal number.
Next: Write a program in C++ to compute the sum of the digits of an integer.
What is the difficulty level of this exercise?