Find the second maximum in an array?

Answer Posted / adnan sheikh

int SecondMax(int Array[], int ALength)
{
int Fmax,Smax;
Fmax=Smax=Araay[0];
for (int i = 0; i < ALength; i++)
{
if (Array[i] > Smax){
if (Array[i] < Fmax){
Smax = Array[i];
}
else{
Smax = Fmax;
Fmax = Array[i];
}
}
}
return Smax;
}

Is This Answer Correct ?    9 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is polymorphism & list its types in c++?

795


Why do we use using namespace std in c++?

789


How can I learn c++ easily?

810


Explain the use of vtable.

812


How do you clear a set in c++?

793






What are the characteristics of friend functions?

744


Write a program to concatenate two strings.

767


Which sort does c++ use?

782


What is the basic difference between C and C++?

808


What is function overriding in c++?

791


What is c++ iterator?

827


What is the difference between #define debug 0 and #undef debug?

868


What is flag in computer?

790


What is a try block?

824


Show the application of a dynamic array with the help of an example.

830