Write a program that read 2o numbers in and array and
output the second largest number. Can anybody help??
Answer Posted / ada
oid SecondMax(int *a)
{
int *p = a;
int i, max, smax;
smax = max = *p++;
for(i=1;i<20;i++,p++)
{
if(*p>max)
{
smax = max;
max = *p;
}
}
if(smax!=max)
{
cout<<"The second largest number is "<<smax<<endl;
}
else
{
cout<<"There's no second largest number: all elements are
equal"<<endl;
}
}
| Is This Answer Correct ? | 2 Yes | 5 No |
Post New Answer View All Answers
What is singleton class in c++?
What is wrapper class in c++?
What is type of 'this' pointer? Explain when it is get created?
What does n mean in c++?
What is doubly linked list in c++?
What does obj stand for?
Explain the uses of static class data?
What is c++ array?
How can you quickly find the number of elements stored in a static array? Why is it difficult to store linked list in an array?
Which operator cannot overload?
Explain the use of this pointer?
What is an object in c++?
What is the best c++ compiler for windows 10?
What are the four partitions in which c++ compiler divides the ram?
What is #include cmath?