Home / Programs / ? :,Conditional Expression or ternary operator, Find largest number among 3 numbers using ternary operator
Programming Example

? :,Conditional Expression or ternary operator, Find largest number among 3 numbers using ternary operator

👁 1,201 Views
💻 Practical Program
📘 Step by Step Learning
Study this program carefully to understand the logic, output, and explanation in a structured way.

Program Code

#include <stdio.h>
int main()
{
int a, b, c, large;
 
printf("Enter any three number: ");
scanf("%d%d%d",&a,&b,&c);
large=a>b ? (a>c?a:c) : (b>c?b:c);
printf("Largest Number is: %d \n",large);
 
}

Output

Enter any three number: 1 2 3
Largest Number is: 3
Press any key to continue . . .

How to learn from this program

First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.