C Programming Code Examples C > Functions Code Examples program to find maximum and minimum using functions program to find maximum and minimum using functions Write a C program to input two or more numbers from user and find maximum and minimum of the given numbers using functions. How to find maximum and minimum of two or more numbers using functions in C programming. We already learned to find maximum using conditional operator and using many other approaches. Here, I will embed the logic to find maximum within a function. Let us define function to find maximum. First give a meaningful name to our function. Say max() function is used to find maximum between two numbers. Second, we need to find maximum between two numbers. Hence, the function must accept two parameters of int type say, max(int number1, int number2). Finally, the function should return maximum among given two numbers. Hence, the return type of the function must be same as parameters type i.e. int in our case. After combining the above three points, function declaration to find maximum is int max(int number1, int number2);. #include <stdio.h> /* Function declarations */ int max(int number1, int number2); int min(int number1, int number2); int main() { int number1, number2, maximum, minimum; /* Input two numbers from user */ printf("Enter any two numbers: "); scanf("%d%d", &number1, &number2); maximum = max(number1, number2); // Call maximum function minimum = min(number1, number2); // Call minimum function printf("\nMaximum = %d\n", maximum); printf("Minimum = %d", minimum); return 0; } /* Find maximum between two numbers. */ int max(int number1, int number2) { return (number1 > number2 ) ? number1 : number2; } /* Find minimum between two numbers. */ int min(int number1, int number2) { return (number1 > number2 ) ? number2 : number1; }