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 do you mean by global variables?
If we want that any wildcard characters in the command line arguments should be appropriately expanded, are we required to make any special provision? If yes, which?
What is the most powerful coding language?
Suppose that data is an array of 1000 integers. Write a single function call that will sort the 100 elements data [222] through data [321].
How can a called function determine the number of arguments that have been passed to it?
How a new operator differs from the operator new?
How do you instruct your compiler to print the contents of the intermediate file showing the effects of the preprocessor?
What does new in c++ do?
Are c and c++ similar?
What does std mean in c++?
Is swift better than c++?
Explain polymorphism?
What is the full form of india?
Ask to write virtual base class code?
Explain operator overloading.