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

What doescout<<(0==0) print out a) 0 b) 1 c) Compiler error: Lvalue required

970


When should overload new operator on a global basis or a class basis?

1083


How does a C++ structure differ from a C++ class?

1131


If horse and bird inherit virtual public from animal, do their constructors initialize the animal constructor? If pegasus inherits from both horse and bird, how does it initialize animal’s constructor?

1215


What is new in c++?

1104


What are the advantage of using register variables?

1175


Describe protected access specifiers?

1239


Do class declarations end with a semicolon? Do class method definitions?

1156


Which is the best c++ compiler?

1086


What are pointer-to-members? Explain.

1155


How do you clear a set in c++?

1081


Is c++ low level?

1039


How do you flush std cout?

1105


What is std namespace in c++?

1189


Write about the local class and mention its use?

1084