Skip to content
Home » Finding Largest in Two Number in C

Finding Largest in Two Number in C

Learn about Finding Largest in Two Number in C in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.

Finding Largest in Two Number in C

The below C code takes two numbers as input from the user and checks which is bigger. The comparisions are done between the numbers using if-else statements. Finally the appropriate result will get displayed.

Source code:

 #include<stdio.h>
 int main()
 {
   int a,b;

   printf("Enter two numbers: ");
   scanf("%d %d",&a,&b);

   if(a>b)printf("a is bigger");
   else if(b>a) printf("b is bigger");
   else printf("Both are same");

   return 0;
 }

Output:

Enter two numbers: 7 9
b is bigger

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

Similar Codes :
C Program to Find Even or Odd using if-else
C Program to Find Positive or Negative