Computer Science, asked by anaghadevadas0084, 3 months ago

largest and second largest number from a set of n numbers. c program​


pea4518977: Please marks as brainliest

Answers

Answered by RedHood3
0

Answer:

;)

Explanation:

Logic to find second largest element

Declare two variables max1 and max2 to store first and second largest elements. Store minimum integer value in both i.e. max1 = max2 = INT_MIN . Iterate though all array elements, run a loop from 0 to size - 1 . Loop structure should look like for(i=0; i<size; i++) .

Answered by pea4518977
0

Answer:

Image result for c program to find largest and second largest number in an array

Iterate though all array elements, run a loop from 0 to size - 1 . Loop structure should look like for(i=0; i<size; i++) . Inside loop, check if current array element is greater than max1 , then make largest element as second largest and current array element as largest. Say, max2 = max1 and max1 = arr[i] .

Explanation:

Similar questions