Find the second maximum in an array?

Answer Posted / foreverkushal

int SecondMax(int *Array, int ACount)
{
int Fm = 0, Sm = 0;
for (int i = 0; i < ACount; i++)
{
if (Array[i] > Sm)
{
if (Array[i] < Fm) Sm = Array[i];
else
{
Sm = Fm;
Fm = Array[i];
}
}
}
return Sm;
}

Is This Answer Correct ?    31 Yes 22 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Define upcasting.

594


Is facebook written in c++?

564


Describe friend function & its advantages.

719


What are formatting flags in ios class?

614


Is swift a good first language?

592






How does a copy constructor differs from an overloaded assignment operator?

562


What is searching?

662


What is c++ good for?

589


Describe Trees using C++ with an example.

610


Is c++ map a hash table?

570


Which recursive sorting technique always makes recursive calls to sort subarrays that are about half size of the original array?

614


How do I start a c++ project?

591


What are static variables?

621


What is a pdb file?

544


Define pointers?

613