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 hash table in c?

1025


Can you tell me how to check whether a linked list is circular?

1430


What is a stream water?

1226


What is the difference between struct and typedef struct in c?

1128


What is a const pointer in c?

1133


given post order,in order construct the corresponding binary tree

2792


Describe newline escape sequence with a sample program?

1124


What are the types of type specifiers?

1046


What are the types of pointers in c?

1029


How many levels of pointers have?

1056


A c program to display count values from 0 to 100 and flash each digit for a secong.reset the counter after it reaches 100.use for loop,. pls guys hepl me.. :(

2257


Is c compiled or interpreted?

1196


What is the use of function overloading in C?

1178


what is the height of tree if leaf node is at level 3. please explain

2153


Explain c preprocessor?

1119