Home C Programming Language / Programs / if- else ladder enter two number and check they are equal, grater or less to each other
🚀 Programming Example

if- else ladder enter two number and check they are equal, grater or less to each other

👁 1,405 Views
💻 Practical Program
📘 Step Learning
Learn this program step-by-step with algorithm, source code, output and detailed explanation.
No previous program
No next program

💻 Program Code

#include"stdio.h"
int main()
{
    int number1, number2;
    printf("Enter two integers: ");
    scanf("%d %d", &number1, &number2);

    //checks if two integers are equal.
    if(number1 == number2)
    {
        printf("Result: %d = %d \n",number1,number2);
    }

    //checks if number1 is greater than number2.
    else if (number1 > number2)
    {
        printf("Result: %d > %d \n", number1, number2);
    }

    // if both test expression is false
    else
    {
        printf("Result: %d < %d \n",number1, number2);
    }

    return 0;
}
                        

🖥 Program Output

Enter two integers:  12   13
Result: 12 < 13
Press any key to continue . . .
                            
No previous program
No next program
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.