C Program to find largest between two numbers

Simple C program to find largest number between two numbers.
#include<stdio.h>
int main()
{
 int a,b;
 printf("Enter first number: ");
 scanf("%d",&a);
 printf("Enter second number: ");
 scanf("%d",&b);
 if(a>b)
 {
  printf("Largest= %d\n",a);
 }
 else
 {
  printf("Largest = %d\n",b);
 }
 return 0;
}
Another C program using conditional operator
#include<stdio.h>
int main()
{
 int a,b;
 printf("Enter first number: ");
 scanf("%d",&a);
 printf("Enter second number: ");
 scanf("%d",&b);
 a>b?printf("Largest= %d",a):printf("Largest= %d",b);
 return 0;
}

Popular posts from this blog