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

Answer Posted / guest


max = 2ndmax= array[0];
for (i=0;i,length;i++)
{
if (array[i]>max)
{
2ndmax=max;
max=array[i];
}
}
return 2nd max

Is This Answer Correct ?    40 Yes 74 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

write a programming in c to find the sum of all elements in an array through function.

1710


What is bubble sort technique in c?

594


Explain what are bus errors, memory faults, and core dumps?

794


4-Take two sets of 5 numbers from user in two arrays. Sort array 1 in ascending and array 2 in descending order. Perform sorting by passing array to a function mySort(array, sortingOrder). Then multiply both the arrays returned from function, using metric multiplication technique in main. Print result in metric format.

1731


What is null pointer in c?

598






What is the difference between malloc() and calloc() function in c language?

608


Describe wild pointers in c?

644


Design a program which assigns values to the array temperature. The program should then display the array with appropriate column and row headings.

1770


what is the c source code for the below output? 5555555555 4444 4444 333 333 22 22 1 1 22 22 333 333 4444 4444 5555555555

2539


Why is C language being considered a middle level language?

658


Which is not valid in C a) class aClass{public:int x;}; b) /* A comment */ c) char x=12;

616


How can you tell whether a program was compiled using c versus c++?

622


How can you invoke another program from within a C program?

620


Explain what is the difference between the expression '++a' and 'a++'?

629


What is string concatenation in c?

570