Computer Science, asked by Mustansir8308, 1 year ago

To find maximum and minimum elements in array c program

Answers

Answered by mrsBhati
0
Logic to find maximum and minimum element in array
Below is the step by step descriptive logic to find maximum or minimum in array.

Input size and element in array, store it in some variable say size and arr.
Declare two variables max and min to store maximum and minimum. Assume first array element as maximum and minimum both, say max = arr[0] and min = arr[0].
Iterate through array to find maximum and minimum element in array. Run loop from first to last array element i.e. 0 to size - 1. Loop structure should look like for(i=0; iInside loop for each array element check for maximum and minimum. Assign current array element to max, if (arr[i] > max). Assign current array element to min if it is less than min i.e. perform min = arr[i] if (arr[i] < min).
Similar questions