៥. ស្វែងរកចំនួនធំបំផុត និងតូចបំផុតចំនោម៣ចំនួន

លំហាត់ទី៥

  • ស្វែងរកចំនួនធំបំផុត និងតូចបំផុតចំនោម៣ចំនួន?

Source

#include <stdio.h>

int main(){

    float x, y, z, max, min;
    printf("\nEnter 3 number x, y, z: ");
    scanf("%f %f %f", &x, &y, &z);

    max = (x>y)?x:y;
    max = (max>z)?max:z;

    min = (x<y)?x:y;
    min = (min < z)?min:z;

    printf("Max number of %.2f, %.2f and %.2f is: %.2f", x, y, z, max);
    printf("\nMin number of %.2f, %.2f and %.2f is %.2f\n\n", x, y, z, min);
    return 0;
}

Output

Enter 3 number x, y, z: 4 5 0.99
Max number of 4.00, 5.00 and 0.99 is: 5.00
Min number of 4.00, 5.00 and 0.99 is 0.99