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 incorrect operator form following list(== , <> , >= , <=) and what is the reason for the answer?
What is meant by type casting?
The statement, int(*x[]) () what does in indicate?
difference between native and cross compilers
What is the difference between a function and a method in c?
Why c is called top down?
In C language, a variable name cannot contain?
Can a file other than a .h file be included with #include?
What is switch in c?
How are pointers declared in c?
What is the size of empty structure in c?
What does return 1 means in c?
‘SAVEPOINT’ and ‘ROLLBACK’ is used in oracle database to secure the data comment. Give suitable examples of each with sql command.
What is multidimensional arrays
What are pointers?