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 are c++ files?
Write a note about the virtual member function?
give me an example for testing a program showing the test path .show how the test is important and complex.
Define a nested class. Explain how it can be useful.
What are structs in c++?
Difference between overloaded functions and overridden functions
What does obj stand for?
Who invented turbo c++?
What is main function in c++ with example?
What are static variables?
Write a program to find the Factorial of a number
Explain about templates of C++.
What is the header file for setw?
Why is that unsafe to deal locate the memory using free( ) if it has been allocated using new?
Write about c++ storage classes?