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 friend classes? What are advantages of using friend classes?

1105


What is a block in c++?

1055


What is a pointer with example?

1264


How do you traverse a btree in backward in-order?

1036


How does code-bloating occur in c++?

1207


What do you mean by stack unwinding in c++?

1234


Is nan a c++?

1156


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

1078


How do you declare A pointer to function which receives an int pointer and returns a float pointer

1230


What is a v-table?

1186


Name four predefined macros.

1043


Is c++ low level?

1037


Explain how functions are classified in C++ ?

1237


How does c++ sort work?

985


What is new in c++?

1103