Find the second maximum in an array?

Answer Posted / navs

if we take the array as
arr[]={1,4,7,2,10,0,6}

get the count

int count =6;
int max =arr[0];
int smax;

for (i=0;i<=count;i++)
{
if(max<arr[i])
{
smax=max;
max=max[i];
}
}

smax would give the second largest number

Is This Answer Correct ?    0 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is struct c++?

574


Why do we use iterators?

622


Which is the best c++ software?

612


Is c++ a dying language?

591


What is abstraction c++?

594






Is swift faster than go?

619


what are Access specifiers in C++ class? What are the types?

632


What does flush do c++?

559


What is one dimensional array in c++?

584


What is the function to call to turn an ascii string into a long?

605


Which c++ compiler is best?

590


What is a friend function in c++?

583


What is a multiset c++?

555


What function initalizes variables in a class: a) Destructor b) Constitutor c) Constructor

680


What is c++ good for?

589