C program to find two largest elements in a one dimensional array
Write a C program to find two largest elements in a one dimensional array.
Example: Type1: (all the elements are not same & no of element is more than two)
Input:
Array size: 4
Elements: 32 54 -6 43
Output:
54 43
Example: Type2: (second maximum doesn’t exist as size of array < 2)
Input:
Array size : 1
Elements: 4
Output:
4
Example: Type3: (all elements are same, thus only one largest element)
Input:
Array size : 4
Elements: 12 12 12 12
Output:
12
Algorithm:
Only one largest value exists, print it
Else
Print max & sec_max
C implementation to find two largest elements in a one dimensional array
Output
need an explanation for this answer? contact us directly to get an explanation for this answer