find maximum and second maximum number in array

Solutions on MaxInterview for find maximum and second maximum number in array by the best coders in the world

showing results for - "find maximum and second maximum number in array"
María Camila
04 Sep 2020
1#include <stdio.h>
2int main() {
3    int i, n;
4    float arr[100];
5    printf("Enter the number of elements (1 to 100): ");
6    scanf("%d", &n);
7
8    for (i = 0; i < n; ++i) {
9        printf("Enter number%d: ", i + 1);
10        scanf("%f", &arr[i]);
11    }
12
13    // storing the largest number to arr[0]
14    for (i = 1; i < n; ++i) {
15        if (arr[0] < arr[i])
16            arr[0] = arr[i];
17    }
18
19    printf("Largest element = %.2f", arr[0]);
20
21    return 0;
22}
23
Franco
08 Oct 2019
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
how to find the maxnimum element in an arraysecond largest number in array c 2b 2bfind max value in array c programminghow to find the maximum element in an array in node jsgiven an array a of n integers find maximum value of a 5bi 5d a 5bj 5bfind biggest number from arrayprint maximum number in array javafind max numner from arrayget max value in array of arrayshow to get smallesr or biggest number in 2 arrays function c programhow to find the max number in the array 22 2f 2fsearch the maximum value in array a 22find largst number in arraymax element in an arrayfunction to find largest number in arrayfind maximum vlaue from an arraymaximum element in an array using functionshow to find the largest value in an arraryoutput largest number in arrayfiund highest number in arraythe biggest number in arrayhow to find max value of number in cfind minimum roi of arraymaximum element in arrayuse a large value in array in cbest way to find maximum element in a araaywrite a program to find the maximum element in an arrayfind max number cfind largest element in arrayhow to always find the largest element of an arraymethod to find max number in an array of intsgiven array and length 2c find largest number in cmax number in arrayhow to find the largest number in an array 28c 2b 2b 29find highest number in an arrayfind maximum based on an array indexfind max 3 numbers in arrayto find maximum and minimum element in arrayfind maximum element in array in csecond maximum in arraymaximum and in arrayfind max value in array under valuemax element in arrayfind maximum count element in arrayfind maximum element of arrayhow to check max number in an arryato find maximum element in arraylargest number in an array in cmaximum and min element in arrayfind bigger number on an arrayfind maximum number of elements where a 5bi 5d 25a 5bj 5d 3d 3d0find the max value of any arrayhow to find biggest number in array in cfind out the maximum and minimumfrom an arrayfinding the biggest item in an arrayfind max element in array in cc program to find largest element in array in c programmingget max from arrayc program to find largest number in a matrix using functionhow to find the second largest element in an array in c 2b 2bprogram to find the maximum element in an array using function how to find largest element in multisefind max element in two array in cfind biggest number in an arrayextract largest elementfind the largest integer in an array in cmethod to find maximum number in arrayfind the maximum element in an array in cgreatest number in arrayget the max number in an arrayalgorithm to find the largest element in an arraycode for largest element in arrayfind maximum numbers position in an arrayfunction to find max in array elementssecond maximum number in array c 2b 2bread 10 integers from the user and store them in an array then find the largest element in the array best way to find maximum and minimum element in arrayhow to get the large element in arrayc 2b 2b find second largest number in arrayfind maximum from arrayhighest and second highest number from array c 2b 2bhow to find largest number in arraywrite code to return the largest number in the given arrayfinsing the largest number in an arrayfind the greatest number in an arraymax element in the array thwe the program prints the largest elementwrite c 23 program to read size of an array and the element of the array from the usermaximum in arraylargest number in an arrayreturn bin of max value in arrayget max number in array of arraysfind largest number in the arrayhow to find the max of an arrayhow to get maximum number from an arrayhow to print the largest value of an arrayfind the max value in arrayfound all max number in arrayindex of the maximum of an arrayfind larger element in arrayhow to find max of a arrayhow to return a maximum value in an arrayfind maximum number in array in cfind the max in an arrayfind the maximum number can be formed from an arrayfinding minimum element in an arrayfinding the biggest number in an arrayhow to find max number in array without using math methodfind max 2th element in arrayhow to get the largest number in an array in csecond maximum number in arrayhow to find largest element in matrix chow to find biggest element in an arrayhow to determine the largest number in an arraymax in array in cwrite a c code to initialize a 5 length array of integer find the biggest number from the array find the maximum number in an array of numbersfind maximum element in arrayhow to get maximum value in a arrayfind second largest and second largest number in arr c 2b 2bfind the biggest element in an arrayc find max value in arrayprint array so that it becomes largest value in ccheck maximum value in an arraymost efficient way to find max element in an arrayprogram to find largest element in an arrayfind the largest number in an arraywap to find the maximum number from the array find max value in arrayfind second maximum value in an arrayprogram to find highest number in arraymaximum number from array in javascriptfind second largest element in the array c 2b 2bc find max number in arrayhow to compare largest elent in an arraymethod to find max element in arrayget second max value in array best solutionfind maximum number in list jshow to find the second largest number in an array c 2b 2bfind longest element array c programmingfind the max value in a array chow to find biggest value in an arrayform the maximum number from the elements of the arraymaximum element of arrayfind largest umberfind max in arrayc array search for largest numberhow to return the value of the maximum integer in the array largest four element in an array in chow to find maximum values in an arraycount the max num in arrayfind max in array cfinding highest number in array cfinding max min second min second max in array cppmaximum possible number from elements of an arrayfind biggest number in an array cmaximum integer using array elementsarray where a 5bi 5d 25a 5bj 5d 3d 3d0 find maximumhow to find maximum space in chow to find the max value in an arrayhow to find second largest number in array in c 2b 2b2nd largest number in an array c 2b 2barray find biggest numbersecond largest in array c 2b 2bfinding largest umber in arrayfinding max element in array in chow to find maximum element of an arrayfind max number in cfind max number in an array using csecond largest number in an array in cppfind second maximum number in arrayhow to display maximum value in arrayfind largest arrayhow to find maximum of an array in cget max value in arraymaximum digits in an array cfind maximum in an arrayhow to find maximum number in an arraywhat is the highest amount of arrays in cmax num in arraysecond largest from array c 2b 2bmax of int array ccheck the biggest integer in a vector c languagearray check maximum valuemaximum consecutive numbers present in an arraysecond maximum element in an arraylargest element in arrayfind the maximum value in an array without using inbuilt functionsget largest element in array cfind the maximum number in an arrayfind maximum no in arrayfinding maximum element in an array2nd maximum number in arraysecond largest number in array in c 2b 2bfind the largest element in an arrayprogram to find maximum value in an arrayfind largest number how to find a maximum number i array javascriptfinding max in an arrayget maximum element in the arrayfind max element in a arrayfinding max in int array c 3d 2bhow to find the maximum element in an arrayfind max and 2nd max in arrayprint max element in arrayprint maximum number in arrayyou have array of integers find the max value in the arrayuse a big value in array in cfind max and second max numbers in an array c 2b 2b 5creturn maximum value in an arrayhow to find max element in an arraymaximum xor with and element from arrayprogram to find largest number in an arraywrite a function that returns the largest element in a listhow to find second max number in arrayhow to find max element in chow to calculate max of arrayfind maximum and second maximum number in arraymax finder inn a arrayfind max value in array in cfinding highest number in a arrayfind the maximum number of an arraymaximum xor of two numbers in an arrayfind maximum and minimum in an arrayget max element in an arraycalculate maximum number from an arrayarray maximum valuemaximum array elements how to get maximum number in array in cfinding largest number in arrayfind the maximum number in an array in cthe max value in an arrayfinding largest element in an arrayfinding max min second min second max index in array cppfinding highest number in an array cfind highest number from array2nd max in array in c 2b 2bhow to find maximum element in an arrayfind maximum number in a given arrayfind the biggest number in arraymax eleme t in the arraysecond largest element in array in c 2b 2bfind maximum and minimum element in an arrayfind highest number in array2nd max number from array c 2b 2bnumpy find max value in arrayget max value from an array with a given valuefinding maximum in an arrayhow to find the highest number in an arraywrite a c program using an integer array that will add all the elements of the array and find the largest element as separate functions how to find maximum and minimum element in two arraysfind the maximum value in an arrayderivation of algorithms index of largest interger in arrayo notation for finding max number in arrayhow to find second highest number in array c 2b 2bfind max element in array in c 5cc program to find largest element in an array and locationhow to find largest element in arrayjavascript get maximum value in arrayfind maximum element from the given array of integers how to find maximum value from an arrayfin max number in arraylargest number in arrayfind max from arraylargest element in an arrayfind the maximum number of an array javascriptmax number in chow to find the maximum value in an arrayfinding maximum number in an array in cwrite a code to find the largest number in the arryfind maximum and minimum number in array1 d array to find the largest element in an arrayprogram to fin maximum element in the arrayfinding the largest number in an array cfind max sum in arraywith 6 statements find 6th highest number in an arrayfind maximum and minimum value in an arrayhow to find max value in an arrayhow to calculate the maximum present in the array using max functionfind maximum value in array javascriptfind max number in arrayprint the leargest element of arrayfind the max number in arraysecond max value in an arrayhow to find the second largest number in an array in c 2b 2bhow to find max in n element of arrayfind maximum value in a contiguos arrayfind mex oaf arrayhow to find the second maximum element in array in c 2b 2bfind out max element in arrayfind out minimum and maximum numbers in an arraylargest number in array in cmaximum number of 1s in an arrayhow to find second maximum from 3 numbers in c 2b 2bgetting largest element in an arraymaximum and value form array selecting only y elementsprogram to find largest number in arraywrite a program to find the maximum element in an array how to check max number in array in cmaximum between array and a numberhow to find the biggest number in c in an arrayfind the maximum element in an unimodal array highest element in arrayfind maximum number in arrayfind largest number in an array in c 27what is the maximum index value of an arrayhow to find second largest number in array c 2b 2bhow to get maximum of the given arraymaximum integer in an arraymax value in arrayhow to find max number in arrayfinding max element in arrayfind the second maximum value in an arrayhow to find max element in arrayfind the largest element of an arrayhow to find the maximum and minimum in an arraysecond largest element in array c 2b 2bfinding greatest number in an array in chow to find maximum elemnt in ccreate maximum number from arrayhoe to find maximum in arrayfind the max element length in the arraymaximum element in an array in cfind max in array efficientfind the array with max value of array of arrayshow to find the max number from the arrey 3ffind max element in two seperates array in cwap to find out maximum number using arraymax number arraymost efficient way to find the maximum in arrayfinding the largest number in an arrayhow to find maximum numner in an arrayfind the largest num in an arraymaximum and minimum element in arrayhow to find second maximum no in an arrayfind second largest number in array c 2b 2b2nd maximum number from an arraytake out maximum value from arrayhow to find the largest element in an arrayalgorithm to find maximum number in an arrayhow to find the greatest number in an arrayfind maximum in arraymax numer for in arraywrite a program to find maximum number in an array maximum among the arraylargest element in an array using function in cfind the largest element in an array in c programprogramming function to find the biggest number in an arrayfind maximum and minimum number arraysecond max number in array c 2b 2bdisplay a maximum element in an arrayget the max element in the arrayfidn the maximum number in an arrayfind largest number in arraymaximum element in an arrayhow to find 2nd highest number in array c 2b 2bhow to check which number is greater in the arrayc max of arrfind largest number in array in cfinding maximum value of n elements of arrayhow to calculate the maximum present in the arrayfind maximum element in cfind second largest element in array c 2b 2bwrite a program to find the maximum number in an array in chow to find biggest value form an array c programminghow to find the highest element in an arrayhow to find greater number in arrayc 2b 2b find second biggest number in arrayhow to find the largest number in an array in cfind second max value in an arrayhow to find the biggest number in an arraygetting the biggest element in an arraycalculate max from an arraywap to find maximum element in an arrayhow to check maximum number and second without array maximum in c 2b 2bfind a maximum value in an arrayhow to find biggest number in arrayc find largest number in arraymaximum of all the numbers of an arrayhow to find max number in an arrayfind maximum capacity in an arrayhow to find largest element in an arraymax element in an array in cfind the maximum number in an array of numbers javascriptfind largest in arrayfind maximum value in arrayhow to find maximum and minimum value of a arrayhow to check greates number in an array c2nd highest max in an arraywrite a functions to find largest element in an matrix c programreturn the largest integer in array in chow to get the biggest number in an array cmaximum no in integer array in chow to find the largest number in an arrayfind max value in an arrayc program to find location of largest element in an array number of maximum values from array javascripthow to find maximum in arrayfind max in array algorithmmaximum number in arrayhow to find maximum number iin arrayshow to get the largest element in an arrayfind the greatest number in an array in cffind the maximum value in an arraydisplay the max value in an arraymax number in array of numberswrite a c program to find maximum element in array find the largest element in an arrayc maximum of arrayarray find out max value 5cbiggest number in arrayhow to find max value in arrayfind the maximum element in an arrayhighest number in arrayfind max in array code examplemaximum and value in an arrayprint the largest number in an arrayimplement maximum value of arrayfind max of arrayhow to greatest number in arrayfunction to find maximum of an arraygetting maximum number in an arrayhow to find second largest number in c 2b 2b without using arrayfind maximum arrayhow to find max element in array in cfind the max vlaue present in an arrayarray of maximum of n elements of arraymaximum element in the array in cget max in arrayfind the maximum and minimum element in an arrayfind out the maximum number in an array in javascripthow to find 2nd maximum number in arraycheck largest number in arraymaximum number of elements in an array formulahow to find max number in array algorithmfind maximum digit of number in arrayfind all max number in arrayhow to find max number in array in chow do you find the second maximum number from an arrayfind maximum and minimum of arrayfind highest and second highest number in arrayget max number in arrayhow to find minimum element in an arrayhow to find max value of an arraymax elemtent in arrayhow to get maximum number from an array in javascripthow to find max no element in arrayfind array in array with max length2nd max element in array c 2b 2bget maximum value in arrayc program to find max number in array by functionfastest way to find max value in arrayarray maximum number in cget largest number in arraysecond max number in arrayc program to find greatest number in an arrayreturn the highest 2 values in an arrayfind the highest number in an arrayhow to find highest number from arrayfinding maximum element in an array using max how to get the maximum number of a js arrayhow to find max from integers in arrayfinding greatest number in an arrayc code to find the largest number in arraymaximum number of items with given valuewhat is the best way to find the largest number in an array 3ffind max element in arrayhow to find maximum number in arraycheck the highest number in an array c programminggreatest in arrayfind maximum and second maximum number in array