 # C Program To Find Maximum And Minimum Numbers In An Array

C Program To Find Maximum And Minimum Numbers In An Array. If you are looking for finding maximum and minimum elements of an array program, this C programming tutorial will help you to learn how to write source code for finding maximum and minimum numbers in an array.

## C Program To Find Maximum And Minimum Numbers

Learn how to write a c Program to find maximum and minimum numbers in an array. Writing minimum and maximum numbers program in C can be done using various techniques but here in this program, we show how to write a c program to find maximum and minimum elements in array in a proper way. Happy coding.

## C Program To Find Maximum And Minimum Elements – Source Code

You can copy paste the below C Program to find maximum and minimum numbers in an array using for loop, in c compiler to check how the source code work.

Example Source Code:

```/* C program to find maximum and minimum numbers in array */

#include <stdio.h>
int main()
{
//variable declaration
int arr; //array of integer type declaration
int i, max, min, size; //integer variables

/* Asking user to enter size of the array */
printf("Enter size of the array: ");
scanf("%d", &size); //reading array size from user

/* Asking user to enter array elements */
printf("Enter elements in the array: ");
for(i=0; i<size; i++)
{
}

/* Assume first element as maximum and minimum */
max = arr;
min = arr;

/* Finding maximum and minimum elements in an array */
for(i=1; i<size; i++)
{
/* If current element of array is greater than max */
if(arr[i]>max)
{
max = arr[i];
}

/* If current element of array is smaller than min */
if(arr[i]<min)
{
min = arr[i];
}
}

/* Printing maximum and minimum elements of an array */
printf("Maximum element = %d\n", max);
printf("Minimum element = %d", min);

return 0;
}```

### C Program To Find Maximum And Minimum Elements – Output

After you compile and run the above c program to find maximum and minimum numbers in array, your C compiler asks you to enter the array size and array elements. After entering size and elements, compiler will check for maximum and minimum numbers and display.

Output:

Enter size of the array:
Enter elements in the array: 5 10 15 -5 20
Maximum element = 20
Minimum element = -5