Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is the use of c++ programming language in real life?

978


What is a container class? What are the types of container classes in c++?

1153


Differentiate between an external iterator and an internal iterator?

944


In what situations do you have to use initialization list rather than assignment in constructors?

1012


How the endl and setw manipulator works?

964


What do manipulators do?

962


What are move semantics?

1081


How would you obtain segment and offset addresses from a far address of a memory location?

1027


What does catch(…) mean?

1066


Why are pointers not used in c++?

1080


Who discovered c++?

984


Draw a flow chart and write a program for the difference between the sum of elements with odd and even numbers. Two dimensional array.

6342


Mention the purpose of istream class?

1062


Using a smart pointer can we iterate through a container?

1022


Perform addition, multiplication, subtraction of 2-D array using Operator Overloading.

3794