Comparison Operators
C++
Easy
2 views
Problem Description
Compare two numbers using all comparison operators.
Real Life: Like comparing prices, ages, scores etc.
Step-by-Step Logic:
1. Take two numbers
2. Use ==, !=, >, =,
Official Solution
void operator_q3_comparison() {
int a = 15;
int b = 20;
cout << "a = " << a << ", b = " << b << endl;
cout << "a == b: " << (a == b) << endl;
cout << "a != b: " << (a != b) << endl;
cout << "a > b: " << (a > b) << endl;
cout << "a < b: " << (a < b) << endl;
cout << "a >= b: " << (a >= b) << endl;
cout << "a <= b: " << (a <= b) << endl;
}
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!