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
Does dev c++ support c++ 11?
Can we run c program in turbo c++?
what are the types of Member Functions?
What does #define mean in c++?
Write a program which uses Command Line Arguments
How much do coding jobs pay?
Evaluate the following expression as C++ would do :8 * 9 + 2 * 5 a) 82 b) 79 c) 370 d) list
Tell me what are static member functions?
Is c++ a good beginners programming language?
What are register variables?
What is the best way to take screenshots of a window with c++ in windows?
What is c++ iterator?
Can I learn c++ without learning c?
Do vectors start at 0?
What does it mean to declare a member variable as static?