Write a c program for finding the max and min from the three numbers

 #include <stdio.h>


int main() {

    int a, b, c;

    int max, min;


    // Taking input

    printf("Enter three numbers: ");

    scanf("%d %d %d", &a, &b, &c);


    // Finding maximum

    if (a > b && a > c)

        max = a;

    else if (b > c)

        max = b;

    else

        max = c;


    // Finding minimum

    if (a < b && a < c)

        min = a;

    else if (b < c)

        min = b;

    else

        min = c;


    // Displaying results

    printf("Maximum number = %d\n", max);

    printf("Minimum number = %d\n", min);


    return 0;

}

Output:



Comments