Call us at 0700-922-6559 or Click here

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 Largest\n”, num2);

   }

   else

   {

       printf(“Both are Equal\n”);

   }

   return 0;

}

Output-

Please Enter Two different values

10 50

50 is Largest

Leave a Reply

Your email address will not be published. Required fields are marked *