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
What is the explanation for the dangling pointer in c?
What is scope rule of function in c?
What is echo in c programming?
What are dangling pointers in c?
Write a program to print numbers from 1 to 100 without using loop in c?
What is 'bus error'?
what is the format specifier for printing a pointer value?
What is a structure member in c?
What library is sizeof in c?
Is c pass by value or reference?
What is a substring in c?
What is struct node in c?
What is the argument of a function in c?
is it possible to create your own header files?
what is the basis for selection of arrays or pointers as data structure in a program