VOOZH about

URL: https://www.geeksforgeeks.org/c/c-program-to-find-the-maximum-and-minimum-element-of-the-array/

⇱ C Program to Find the Maximum and Minimum Element in the Array - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

C Program to Find the Maximum and Minimum Element in the Array

Last Updated : 12 Jul, 2025

In this article, we will discuss different ways to find the maximum and minimum elements of the array in C.

The simplest method to find the maximum and minimum element of the array is iterates through the array and compare each element with the assumed minimum and maximum and update them if the current element is smaller or larger respectively.


Output
7
2

Explanation: We passed the variables to store the minimum and maximum element to findMinMax() function as to avoid the complex techniques to pass multiple values from function.

C also have a few other methods to find the maximum and minimum element of the array that are useful in different cases. Let’s take a look at them one by one:

Using Recursion

In this approach, we search for the maximum and minimum values by checking each element the array using recursion.


Output
7
2

By Sorting

The largest and smallest element can be easily determined by sorting the array using qsort() function. If the array is sorted in ascending order, the smallest element will be at the beginning (0-th index), and the largest will be at the end (size - 1 index) of the array.


Output
7
2

This method is simple to implement but has a higher time complexity.

Comment
Article Tags:
Article Tags: