Home / 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,402 Views
💻 Practical Program
📘 Step by Step Learning
Study this program carefully to understand the logic, output, and explanation in a structured way.

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;
}

Output

Enter two integers:  12   13
Result: 12 < 13
Press any key to continue . . .

How to learn from this program

First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.