Computer Science, asked by Chiragrock830, 7 hours ago

accept 2 numbers and display whether both are equal or 1st number is bigger than 2nd or 2nd is bigger than 1st in 'C' program.

Answers

Answered by anindyaadhikari13
13

\textsf{\large{\underline{Solution}:}}

The given problem is solved using language - C.

#include <stdio.h>

int main() {

   int a,b;

   printf("Enter a number: ");

   scanf("%d",&a);

   printf("Enter another number: ");

   scanf("%d",&b);

   if(a==b)

       printf("Both the numbers are equal.");

   else if(a>b)

       printf("First number is greater than the second.");

   else

       printf("Second number is greater than the first.");

   return 0;

}

\textsf{\large{\underline{Logic}:}}

  1. Accept two numbers from the user, say a and b.
  2. Check if a = b. If true, both are equal.
  3. If false, check if a > b. If true, first number is greater than second or else, second number is greater than first.
  4. Display the required output.

See attachments for output.

Attachments:
Similar questions