c code to find min max between 3 numbers

  • cmin-max
  • max and min between three numbers

    write a c program to find the maximum and minimum between three numbers using function.

    Code

    #include <stdio.h> #include <stdlib.h> #include <string.h> int maximum(int a, int b, int c) { if (a > b && a > c) { return a; } if (b > a && b > c) { return b; } if (c > a && c > b) { return c; } } int minimum(int a, int b, int c) { if (a < b && a < c) { return a; } if (b < a && b < c) { return b; } if (c < a && c < b) { return c; } } int main() { int x, y, z, a, b; printf("enter the three numbers\n"); scanf("%d", &x); scanf("%d", &y); scanf("%d", &z); a = maximum(x, y, z); b = minimum(x, y, z); printf("maximum and minimum are: %d and %d\n", a, b); return 0; }