Find Maximum and Minimum value from an Array using C Programming

Опубликовано: 25 Июль 2024
на канале: TrustCoding
214
1

C program to find the maximum and minimum element of the array
বাংলায় কম্পিউটার প্রোগ্রামিং | C Programming in Bengali

Given an array arr[] of N integers, the task is to write the C program to find the maximum and minimum element of the given array iteratively and recursively. Examples:

Input: arr[] = {1, 2, 4, -1} Output: The minimum element is -1 The maximum element is 4 Input: arr[] = {-1, -1, -1, -1} Output: The minimum element is -1 The maximum element is -1

Approach:

Let maxE and minE be the variable to store the minimum and maximum element of the array.
Initialise minE as INT_MAX and maxE as INT_MIN.
Traverse the given array arr[].
If the current element is smaller than minE, then update the minE as current element.
If the current element is greater than maxE, then update the maxE as current element.
Repeat the above two steps for the element in the array.
Iterative approach
Below is the implementation of the Iterative approach:

   • Find Maximum and Minimum value from an Arr...  

Regards,
Md. Ahsan Arif
University of Scholars

#cprogramming #education #ius #universityofscholars #ius #coding #cprogrammingtutorial #trustcoding #banglatutorial #bangladesh #bangla


На этой странице сайта вы можете посмотреть видео онлайн Find Maximum and Minimum value from an Array using C Programming длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь TrustCoding 25 Июль 2024, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 214 раз и оно понравилось 1 зрителям. Приятного просмотра!