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

int max,secMax;
int A[100];
if(A[0]>A[1])
{
max=A[0];
secMax=A[1];
}
else
{
max=A[1];
secMax=A[0];

}


for(i=2;i<=length of Array;i++)
{
if (A[i]>max )
{
secMax=max;
max=A[i];
}
else if(array[i]>secMax)
{
secMax = A[i];
}

}

Is This Answer Correct ?    7 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the explanation for the dangling pointer in c?

1059


What is scope rule of function in c?

1025


What is echo in c programming?

962


What are dangling pointers in c?

1114


Write a program to print numbers from 1 to 100 without using loop in c?

1026


What is 'bus error'?

1085


what is the format specifier for printing a pointer value?

965


What is a structure member in c?

954


What library is sizeof in c?

1033


Is c pass by value or reference?

994


What is a substring in c?

994


What is struct node in c?

1015


What is the argument of a function in c?

986


is it possible to create your own header files?

1043


what is the basis for selection of arrays or pointers as data structure in a program

4248