1. Check Equal or Not Equal

Easy ⏱️ 5 min

Problem Statement

Given 2 integer input check whether the 2 input are "Equal" or "Not Equal" and print the corresponding message.

Input Format:
Accept two integers as input
Output Format:
Print the output as "Equal" or "Not Equal"
Constraints:
1 <= INPUT <= 10^15
Sample Input 1:
12345 12345
Sample Output 1:
Equal
Sample Input 2:
278 34
Sample Output 2:
Not Equal
🧱 C++ If-Else Statements Guide
🔀 What is an If Statement?

An if statement allows your program to make decisions based on conditions.

Syntax:

if (condition) { /* code to execute if true */ }

✅ If the condition is true, the code inside the braces runs.

❌ If the condition is false, the code is skipped.

↔️ If-Else Statement

When you want to execute different code based on whether a condition is true or false:

Syntax:

if (condition) { /* true block */ } else { /* false block */ }

Example:

if (a == b) { cout << "Equal"; } else { cout << "Not Equal"; }

⚖️ Comparison Operators

Use these operators to compare values in conditions:

  • == → Equal to (checks if two values are the same)
  • != → Not equal to
  • > → Greater than
  • < → Less than
  • >= → Greater than or equal to
  • <= → Less than or equal to

⚠️ Common mistake: Don't confuse = (assignment) with == (comparison)!

💡 Why Use long long?

The constraint says input can be up to 10^15, which is too large for a regular int.

Data type ranges:

  • int → -2×10^9 to 2×10^9
  • long long → -9×10^18 to 9×10^18 ✅

Since 10^15 exceeds int range, we use long long to safely store large numbers.

💡 Tip: Always check the constraints to choose the right data type!

Solution

#include <iostream>

using namespace std;

int main() {
    long long a, b;
    
    cin >> a >> b;
    
    if (a == b) {
        cout << "Equal";
    } else {
        cout << "Not Equal";
    }
    
    return 0;
}