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
Is string data type in c++?
Is facebook written in c++?
When does the c++ compiler create temporary variables?
What is the importance of mutable keyword?
What is the use of lambda in c++?
What are files in c++?
What is meant by entry controlled loop? What all C++ loops are exit controlled?
What is a singleton c++?
How can virtual functions in c++ be implemented?
Are iterators pointers?
Why is null pointer used?
Define token in c++.
What is a manipulator in c++?
What is the arrow operator in c++?
What is a try block?