write a program to find the greatest among 3 numbers using conditional operator
Answers
Answered by
1
Answer:
In this Program we have used the conditional operator for comparing biggest of three numbers.
# include <stdio.h>
void main()
{
int a, b, c, big ;
printf("Enter three numbers : ") ;
scanf("%d %d %d", &a, &b, &c) ;
big = a > b ? (a > c ? a : c) : (b > c ? b : c) ;
printf("\nThe biggest number is : %d", big) ;
}
Ternary operator takes three arguments
1. condition
2. value to return when condition is met
3. value to return when condition is not met
Similar questions
Math,
3 months ago
History,
3 months ago
Environmental Sciences,
6 months ago
English,
6 months ago
Computer Science,
1 year ago