# Write a C Program to find the Largest Number

Write a C program to find the largest number from three numbers using conditional operators in the C programming Language. Make a program in the C programming language. Solution of the Program is as follows -

/*Write a C program to find the largest number among three numbers using conditional operator */ #include<stdio.h> void main() { int a,b,c,big; printf("\nEnter 3 numbers:\n"); scanf("%d %d %d",&a,&b,&c); big=(a>b&&a>c?a:b>c?b:c); printf("\nThe biggest number is: %d",big); getch(); }

**Input** -

a = 10

b = 15

c = 12

**Processing** -

big=(a>b && a>c ?a : b>c ?b : c);

=> Condition 1 = a>b && a>c ? a

=10>15 && 10>12 ? a – False

=> Condition 2 = b>c ? b

= 15>12 ? b – True

The condition two i.e 15>12 ? b is true. Therefore the 3rd condition will not be evaluated and variable b will be assigned to variable big and hence we have found the biggest number among three numbers and the output will be printed on the screen.

**Output** -

The biggest number is 15

No comments yet