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 c++ array?
By using c++ with an example describe linked list?
What is the sequence of destruction of local objects?
Can create new c++ operators?
Is c++ a low level language?
Can comments be nested?
Which compiler does turbo c++ use?
Write bites in Turbo c++ Header ("Include") Files.
How should runtime errors be handled in c++?
What is null c++?
What is c++ stringstream?
Define friend function.
. If employee B is the boss of A and C is the boss of B and D is the boss of C and E is the boss of D. Then write a program using the Database such that if an employee name is Asked to Display it also display his bosses with his name. For eg. If C is displayed it should also display D and E with C?
How does work in c++?
Differentiate between an external iterator and an internal iterator? What is the advantage of an external iterator.