Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Find the second maximum in an array?

Answer Posted / vili

// this deals with negative numbers as well
int getSecondMax( int* pArray, int nSize )
{
int nMax = pArray[0];
int n2ndMax = pArray[0];
for ( int i = 1; i < nSize; i++ )
{
if ( nMax < pArray[i] )
{
n2ndMax = nMax;
n2ndMax = pArray[i];
}
}
return n2ndMax;
}

Is This Answer Correct ?    6 Yes 22 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of vtable?

1094


Which is better c++ or java?

925


Write about the use of the virtual destructor?

958


What are the various storage classes in C++?

1085


What are friend classes? What are advantages of using friend classes?

1037


Explain what you mean by a pointer.

1052


How do you invoke a base member function from a derived class in which you’ve overridden that function?

1063


What is string in c++ programming?

1107


Should the this pointer can be used in the constructor?

970


Is c better than c++?

1017


Show the declaration for a static member variable.

951


Do you know what are the new features that iso/ansi c++ has added to original c++ specifications?

1013


What is flush programming?

949


What is the disadvantage of using a macro?

1050


What is the basic of c++?

1014