+ 2

Write a program in C to find maximum and minimum of three inputs without using if statement

7th Feb 2018, 3:56 PM
Christia Ruby
Christia Ruby - avatar
4 Answers
+ 14
use array & find max,min of n numbers without any if else
7th Feb 2018, 4:14 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
12th Feb 2018, 5:57 AM
Prop de Puppy
Prop de Puppy - avatar
+ 3
Here it is in C and for three values. #include <stdio.h> int main() { int a, b, c; scanf("%d", &a); scanf("%d", &b); scanf("%d", &c); int max = (a >= b && a >= c) ? a : (b >= a && b >= c) ? b : c; int min = (a <= b && a <= c) ? a : (b <= a && b <= c) ? b : c; printf("max is %d, min is %d", max, min); return 0; }
7th Feb 2018, 5:09 PM
Boris Batinkov
Boris Batinkov - avatar
+ 1
S...We can use it @Marcel Feenstra
7th Feb 2018, 4:24 PM
Christia Ruby
Christia Ruby - avatar