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
Does dev c++ support c++ 11?
What is a volatile variable in c++?
Who discovered c++?
How one would use switch in a program?
What is a storage class used in c++?
What are manipulators used for?
Is overriding possible in c++?
Write a recursive program to calculate factorial in c++.
What is lvalue?
What are references in c++? What is a local reference?
What is & in c++ function?
What are c++ variables?
Explain the difference between overloading and overriding?
Which programming language is best?
What are structs in c++?