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
What is abstraction in c++?
How do you declare A pointer to a function which receives nothing and returns nothing
What is a pointer how and when is it used?
What are the 2 main types of data structures?
What are the types of pointer?
What is c++ coding?
What is private public protected in c++?
Define virtual constructor.
What is &x in c++?
What is the use of class in c++?
Write a code/algo to find the frequency of each element in an array?
Explain the uses of static class data?
Which is the best c++ software?
How do you declare A pointer to function which receives an int pointer and returns a float pointer
Can you write a function similar to printf()?