find second largest element in array w/o using sorting
techniques? use onle one for loop.

Answer Posted / ramesh

this is to largest element in an array using one loop concept:

for(int i=0;i<=arr.length;i++)
{
if(a[i]>a[i+1])//if first position element is large we want swap that element
{
t =a[i];
a[i] =a[i+1];
a[i+1]=t;
}
printf("%d",a[i+1]);

by
97894 33227

Is This Answer Correct ?    1 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is scope of variable in c?

571


Why isn't any of this standardized in c? Any real program has to do some of these things.

626


What is the use of sizeof?

556


Is there a way to switch on strings?

621


Differentiate between null and void pointers.

633






What would be an example of a structure analogous to structure c?

576


Write programs for String Reversal & Palindrome check

598


What is array of pointers to string?

570


Discuss the function of conditional operator, size of operator and comma operator with examples.

680


what does static variable mean?

657


How can I remove the trailing spaces from a string?

616


process by which one bit patten in to another by bit wise operation is? (a) masking, (b) pruning, (c) biting, (d) chopping,

1892


Write a C Program That Will Count The Number Of Even And Odd Integers In A Set using while loop

1717


Explain how does flowchart help in writing a program?

634


Multiply an Integer Number by 2 Without Using Multiplication Operator

323