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

what are the characteristics of Class Members in C++?

1032


Is it possible to provide special behavior for one instance of a template but not for other instances?

1122


What are structs in c++?

1026


What is the main function c++?

1102


Explain terminate() function?

1042


What is c++ redistributable?

1215


What does ctime() do?

1114


What are virtual functions in c++?

1166


What is a namespace in c++?

2000


What do you know about near, far and huge pointer?

1124


What do you understand by pure virtual function? Write about its use?

992


Why #include is used?

1054


What is the full form of india?

1112


Is it legal in c++ to overload operator++ so that it decrements a value in your class?

1047


What is the difference between a template and a macro?

1046