FIND GREATEST AMONG 3 NUMBERS USING CONDITIONAL OPERATOR IN C PROGRAM








Find the greatest number in given three numbers

#include<stdio.h>
int main(){
int a,b,c,big;
printf("\nEnter 3 numbers:");
scanf("%d %d %d",&a,&b,&c);
big=(a>b&&a>c?a:b>c?b:c);
printf("\nThe biggest number is:%d",big);
return 0;
}




C program for largest of 3 numbers
Write a c program to find largest of three numbers


#include<stdio.h>
int main(){
  int a,b,c;
  int big;
   
  printf("Enter any there numbers: "); 
  scanf("%d%d%d",&a,&b,&c);


  if(a>b && a>c)
    big = a;
   else if(b>c)
    big = b;
   else
    big = c;
   
   printf("Largest number is: %d",big); 


  return 0;
}


Sample output:


Enter any there numbers: 13 25 6
Largest number is: 25





Post a Comment