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++ library?
When does a name clash occur in c++?
Does c++ support multilevel and multiple inheritances?
Name the debugging methods that are used to solve problems?
How do you clear a map in c++?
Why is null pointer used?
What is wrapper class in c++?
Name the implicit member functions of a class.
Differentiate between an inspector and a mutator ?
What is a local reference?
There are 100 students in a class. The management keep information in two tables. Those two tables are given like Roll no Name Age 001 ABC 15 002 XYZ 14 and Roll No Subject Marks 001 Math 75 001 Physics 55 002 Math 68 001 Hindi 69 They want the information like this Roll No Name Hindi Physics Math Total 001 ABC 69 55 75 199 002 XYZ 68 74 84 226 And Roll No Suject Highest 001 Math 98 007 Physics 84 021 Hindi 74 All 275 All information is kept in structure in main memory. You have to find last two tables.
What are smart pointers?
Define upcasting.
What is the word you will use when defining a function in base class to allow this function to be a polimorphic function?
Why do we use templates?