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 is singleton class in c++?

1015


What is wrapper class in c++?

1068


What is type of 'this' pointer? Explain when it is get created?

993


What does n mean in c++?

1100


What is doubly linked list in c++?

1046


What does obj stand for?

1113


Explain the uses of static class data?

1070


What is c++ array?

1053


How can you quickly find the number of elements stored in a static array? Why is it difficult to store linked list in an array?

951


Which operator cannot overload?

1010


Explain the use of this pointer?

1132


What is an object in c++?

1182


What is the best c++ compiler for windows 10?

1013


What are the four partitions in which c++ compiler divides the ram?

1190


What is #include cmath?

1058