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 / ada

oid SecondMax(int *a)
{
int *p = a;
int i, max, smax;

smax = max = *p++;
for(i=1;i<20;i++,p++)
{
if(*p>max)
{
smax = max;
max = *p;
}
}

if(smax!=max)
{
cout<<"The second largest number is "<<smax<<endl;
}
else
{
cout<<"There's no second largest number: all elements are
equal"<<endl;
}
}

Is This Answer Correct ?    2 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is map ordered c++?

1036


Define the operators that can be used with a pointer.

993


Which programming language is best to learn first?

1007


What are vectors used for in c++?

1007


What is the keyword auto for?

989


Discuss the effects occur, after an exception thrown by a member function is unspecified by an exception specification?

1014


Why is c++ so fast?

973


Can non-public members of another instance of the class be retrieved by the method of the same class?

1029


Write a program to interchange 2 variables without using the third one.

1000


What are destructors?

939


What does new do in c++?

1019


Is c++ map a hash table?

968


What is a c++ vector?

987


What are friend functions in C++?

1007


How many types of scopes are there in c++?

1034