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 hash table in c?
Can you tell me how to check whether a linked list is circular?
What is a stream water?
What is the difference between struct and typedef struct in c?
What is a const pointer in c?
given post order,in order construct the corresponding binary tree
Describe newline escape sequence with a sample program?
What are the types of type specifiers?
What are the types of pointers in c?
How many levels of pointers have?
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.. :(
Is c compiled or interpreted?
What is the use of function overloading in C?
what is the height of tree if leaf node is at level 3. please explain
Explain c preprocessor?