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

What is a storage class? Mention the storage classes in c++.

670


What is math h in c++?

689


In c++, what is the difference between method overloading and method overriding?

694


Why do we use iterators?

718


When the constructor of a base class calls a virtual function, why doesn't the override function of the derived class gets called?

685






What is the difference between set and map in c++?

721


What is a sequence in c++?

661


Where are setjmp and longjmp used in c++?

722


What is a c++ vector?

691


What is c++ map?

657


What is c++ library?

686


How does java differ from c and c++?

618


Write a program in c++ to print the numbers from n to n2 except 5 and its multiples

2142


What is function prototyping? What are its advantages?

680


How do we implement inheritance in c++?

687