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 are c++ files?

1079


Write a note about the virtual member function?

1018


give me an example for testing a program showing the test path .show how the test is important and complex.

2885


Define a nested class. Explain how it can be useful.

1054


What are structs in c++?

989


Difference between overloaded functions and overridden functions

1020


What does obj stand for?

1110


Who invented turbo c++?

1029


What is main function in c++ with example?

1170


What are static variables?

1098


Write a program to find the Factorial of a number

1026


Explain about templates of C++.

1116


What is the header file for setw?

1083


Why is that unsafe to deal locate the memory using free( ) if it has been allocated using new?

1032


Write about c++ storage classes?

1160