Write a program that read 2o numbers in and array and
output the second largest number. Can anybody help??
Answer Posted / mms zubeir
void main()
{
int numbers[20];
int biggest=0, secondBiggest=0;
for(int index = 0; index < 20; ++index)
{
int input;
cin>>input;
if(input == biggest)
continue;
if(input > biggest)
{
secondBiggest = biggest;
biggest = input;
}
else if(input > secondBiggest)
secondBiggest = input;
}
cout<<endl<<"Biggest : "<<biggest<<endl<<"Second
biggest : "<<secondBiggest<<endl;
getch();
}
| Is This Answer Correct ? | 6 Yes | 6 No |
Post New Answer View All Answers
How can you quickly find the number of elements stored in a static array?
What is the best free c++ compiler for windows?
Which operations are permitted on pointers?
Explain the concept of friend function in c++?
What are default parameters? How are they evaluated in c++ function?
Difference between overloaded functions and overridden functions
What is difference between malloc()/free() and new/delete?
What are manipulators used for?
Is it possible to get the source code back from binary file?
What is an inline function in c++?
Does std endl flush?
How can a called function determine the number of arguments that have been passed to it?
Explain how the virtual base class is different from the conventional base classes of the opps.
What is #include iomanip?
What is an adaptor class or wrapper class in c++?