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 does #define mean in c++?

1268


What is the difference between while and do while loop?

1150


What do you mean by inheritance in c++? Explain its types.

1133


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

1105


What is a .h file c++?

1037


Is set c++?

996


what you know about c++?

1149


Explain how functions are classified in C++ ?

1225


Which one is a preferred language C or C++? Why?

1087


What is encapsulation in c++?

1289


what is C++ exceptional handling?

1170


Which header file allows file i/o with streams a) fileio.h b) iostream.h c) fstream.h

1129


What is an html tag?

1143


what is Member Functions in Classes?

1192


What is general form of pure virtual function? Explain?

994