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

Explain binary search.

945


What is the function of I/O library in C++ ?

1119


What are arrays c++?

1052


State the difference between delete and delete[].

1036


What is namespace & why it is used in c++?

1041


What is c++ hiding?

1117


Discuss the possibilities related to the termination of a program before entering the mainq method?

901


What is the difference between #import and #include?

993


How to tokenize a string in c++?

1005


What is the protected keyword used for?

1063


Differentiate between a constructor and a method in C++.

996


What is a storage class? Mention the storage classes in c++.

978


Describe protected access specifiers?

1147


What is the precedence when there is a global variable and a local variable in the program with the same name?

1070


What do you mean by function pointer?

1048