Skip to content

C-Program 15

WRITE A PROGRAM to find the larger of two numbers.

#include <stdio.h>
int main()
{
    int num1, num2;
    // Ask user to enter the two numbers
    printf("Please Enter Two different values\n");
    // Read two numbers from the user
    scanf("%d %d", &num1, &num2);
    if(num1 > num2)
    {
        printf("%d is Largest\n", num1);
    }
    else if (num2 > num1)
    {
        printf("%d is Larger\n", num2);
    }
    else
    {
        printf("Both are Equal\n");
    }
    return 0;
}

Output