second maximum number in array c 2b 2b

Solutions on MaxInterview for second maximum number in array c 2b 2b by the best coders in the world

showing results for - "second maximum number in array c 2b 2b"
Mattia
29 Mar 2016
1#include <iostream>
2int main()
3{
4    std::cout << "Enter 5 numbers : ";
5    int arr[5];
6    
7    for (int i = 0; i < 5; std::cin >> arr[i++]);
8
9    int max = arr[0], second = 0;
10
11    for (int i = 1; i < 5; i++)
12        if (arr[i] > max)
13            max = arr[i];
14    std::cout << "Maximum number : " << max << "\n";
15    bool found = false;
16    for (int i = 0; i < 5; i++)
17    {
18        if (arr[i] == max)
19            continue;
20        else if (arr[i] > second)
21        {
22            second = arr[i];
23            found = true;
24        }
25    }
26    if (found)
27        std::cout << "Second maximum numbers : " << second;
28    else
29        std::cout << "Second maximum number not found.";
30}
queries leading to this page
find second largest number in array c 2b 2bhow to find second largest number in array c 2b 2bsecond largest number in array c 2b 2b2nd highest max in an arraysecond maximum number in arrayhighest and second highest number from array c 2b 2bfinding max min second min second max in array cpphow to check maximum number and second without array maximum in c 2b 2breturn the highest 2 values in an arraysecond max number in array c 2b 2bc 2b 2b find second biggest number in arrayfind max and 2nd max in arrayfind second largest element in array c 2b 2bhow to find maximum and minimum element in two arrayssecond largest in array c 2b 2bhow to find the second maximum element in array in c 2b 2bhow to find second largest number in array in c 2b 2bsecond maximum element in an arraysecond max number in array2nd maximum number in arrayget second max value in array best solutionhow to find the second largest element in an array in c 2b 2bfinding max min second min second max index in array cppsecond largest number in array in c 2b 2b2nd largest number in an array c 2b 2bfind second maximum number in array2nd max element in array c 2b 2b2nd max number from array c 2b 2bsecond max value in an arrayfind the second maximum value in an arrayfind second maximum value in an arrayc 2b 2b find second largest number in arraysecond largest number in an array in cpphow to find the second largest number in an array c 2b 2bhow do you find the second maximum number from an arrayfind max 2th element in arrayfind all max number in arraysecond maximum in arrayfind max and second max numbers in an array c 2b 2b 5chow to find second highest number in array c 2b 2bhow to find 2nd maximum number in arrayfind second largest and second largest number in arr c 2b 2bhow to find second maximum no in an arraysecond largest from array c 2b 2bmaximum and value form array selecting only y elementsfind second max value in an arraysecond largest element in array in c 2b 2bmaximum number of 1s in an arrayhow to find 2nd highest number in array c 2b 2bhow to find the second largest number in an array in c 2b 2bhow to find second maximum from 3 numbers in c 2b 2b2nd max in array in c 2b 2bsecond maximum number in array c 2b 2bfind maximum and minimum number array2nd maximum number from an arrayhow to find second max number in arrayfind highest and second highest number in arrayfind the maximum and minimum element in an arrayhow to find second largest number in c 2b 2b without using arraysecond largest element in array c 2b 2bfind second largest element in the array c 2b 2bsecond maximum number in array c 2b 2b