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 :: operator in c++?

575


What is increment operator in c++?

558


What does obj stand for?

625


Can you help me with this one? Make a program that when a user inputed a Product Name, it will display its price, and when the user inputed the quantity of the inputed product, it will show its total price. The output must be like this: Product Name: Price: Quantity: Total Price: ..this is the list of products to be inputed: Cellphone - 1500 Washing Machine - 5200 Television - 6000 Refrigirator - 8000 Oven - 2000 Computer - 11000 thanks..:D

3051


Can you pass a vector to a function?

534






What is the difference between interpreters and compilers?

624


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

672


Can you be able to identify between straight- through and cross- over cable wiring? And in what case do you use straight- through and cross-over?

618


How does com provide language transparency?

600


Should a constructor be public or private?

535


What is prototype for that c string function?

684


What is lvalue?

694


Why is main an int?

524


Write a program which uses functions like strcmp(), strcpy()? etc

613


Explain one method to process an entire string as one unit?

927