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 size of string in c++?

996


What do you mean by vtable and vptr in c++?

1048


What is a singleton c++?

1016


Draw a flow chart and write a program for the difference between the sum of elements with odd and even numbers. Two dimensional array.

6420


What is the meaning of c++?

1036


What is c++ namespace?

1225


Differentiate between a pointer and a reference with respect to c++.

1256


What is vector string in c++?

1099


Why should we use null or zero in a program?

1053


What is abstract class in c++?

1063


How are Structure passing and returning implemented by the compiler?

1160


Can recursive program be written in C++?

1244


What is c++ redistributable?

1243


What are abstract data types in c++?

992


What do you mean by friend class & friend function in c++?

1070