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 are the characteristics of Class Members in C++?
Is it possible to provide special behavior for one instance of a template but not for other instances?
What are structs in c++?
What is the main function c++?
Explain terminate() function?
What is c++ redistributable?
What does ctime() do?
What are virtual functions in c++?
What is a namespace in c++?
What do you know about near, far and huge pointer?
What do you understand by pure virtual function? Write about its use?
Why #include is used?
What is the full form of india?
Is it legal in c++ to overload operator++ so that it decrements a value in your class?
What is the difference between a template and a macro?