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

if we take the array as
arr[]={1,4,7,2,10,0,6}

get the count

int count =6;
int max =arr[0];
int smax;

for (i=0;i<=count;i++)
{
if(max<arr[i])
{
smax=max;
max=max[i];
}
}

smax would give the second largest number

Is This Answer Correct ?    0 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Should I learn c or c++ first?

1124


What are the characteristics of friend functions?

1011


Write about a nested class and mention its use?

1094


What is the difference between cin.read() and cin.getline()?

1076


How to implement is-a and has-a class relationships?

1017


What does it mean to declare a destructor as static?

1082


Is std :: string immutable?

1031


How to declare a pointer to an array of integers?

1137


What is setiosflags c++?

967


What are built-in functions? What is the syntax for the definition?

1073


Explain pass by value and pass by reference.

1052


Describe private, protected and public – the differences and give examples.

1188


What is public, protected, private in c++?

1145


How is data hiding achieved in c++?

1076


Difference between pointer to constant and constant pointer to a constant. Give example.

1111