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 second largest element in array w/o using sorting
techniques? use onle one for loop.

Answer Posted / maxerp

int secondLargestNumber(int a[],int numberOfValues)
{
int largest=secondLargest=a[0];
int i;

for(i=1;i<numberOfValues;i++)
{
if(a[i]>largest)
{
secondLargest=largest;
largest=a[i];
}

if(a[i]>secondLargest && a[i]<largest)
secondLargest=a[i];
}

return secondLargest;
}

Is This Answer Correct ?    29 Yes 14 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a program to print factorial of given number without using recursion?

997


Why functions are used in c?

1145


Why is void main used?

1103


Why is sizeof () an operator and not a function?

1035


What is auto keyword in c?

1209


What is the right type to use for boolean values in c? Is there a standard type?

1018


in case any function return float value we must declare a) the function must be declared as 'float' in main() as well b) the function automatically returned float values c) function before declared 'float' keyword d) all the above

1039


The number of measuring units from an arbitarary starting point in a record,area,or control block to some other point a) recording pointer b) offset c) branching d) none

1258


Explain what are compound statements?

1067


Explain what is wrong in this statement?

1129


i got 75% in all semester am i eligible for your company

2230


What is the description for syntax errors?

1175


What is difference between class and structure?

1121


which of the following statement is wrong a) mes=123.56; b) con='T'*'A'; c) this='T'*20; d) 3+a=b;

3268


What are file streams?

1022