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...

Find the second maximum in an array?

Answer Posted / jaldeep

int sec_max(int a[])
{
if(a[0]>a[1])
{
max=a[0]
sec_max=a[1]
}
else
{
max=a[1]
sec_max=a[0]
}
for(i=1;i<n-1;i++)
{
if (a[i]>sec_max && a[i]< max)
{
sec_max=a[i];
}
else if(a[i]>max)
{
sec_max=max;
max=a[i];
}
return sec_max;
}

Is This Answer Correct ?    5 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Define a nested class.

1035


What is the extension of c++?

937


What is conditions when using boolean operators?

1156


What is set in c++?

1081


What is the insertion operator and what does it do?

1002


What is virtual destructor? What is its use?

1019


How a new element can be added or pushed in a stack?

976


Can user-defined object be declared as static data member of another class?

992


Will rust take over c++?

1022


Explain the auto storage classes in c++.

1063


What are manipulators in c++ with example?

1017


Explain how an exception handler is defined and invoked in a Program.

1135


What is binary object model?

978


Why is c++ so fast?

985


What is abstraction in c++ with example?

1048