Write a program to find largest among three numbers using conditional operator

Write a program to find largest among three numbers using conditional operator


// Write a program to find largest among three numbers using conditional operator
// 3 2 4 -> 4; 10 4 6 -> 10
 
#include
main(){
    int num1,num2,num3,large,temp;
    printf("Enter 3 numbers:");
    scanf("%d %d %d",&num1,&num2,&num3);
    temp=(num2>num3?num2:num3);         // compare second and third numbers and store in temp
    large=num1>temp?num1:temp;          // compare first number with temp
    printf("\nThe Large Number is---->%d",large);
}

No comments:

Post a Comment