find second largest element in array w/o using sorting
techniques? use onle one for loop.
Answer Posted / maxerp
int secondLargestNumber(int a[],int numberOfValues)
{
int largest=secondLargest=a[0];
int i;
for(i=1;i<numberOfValues;i++)
{
if(a[i]>largest)
{
secondLargest=largest;
largest=a[i];
}
if(a[i]>secondLargest && a[i]<largest)
secondLargest=a[i];
}
return secondLargest;
}
| Is This Answer Correct ? | 29 Yes | 14 No |
Post New Answer View All Answers
What are preprocessor directives in c?
What is an expression?
Explain what is the difference between functions abs() and fabs()?
count = 0; for (i = 1;i < = 10; i++);count = count + i; Value of count after execution of the above statements will be a) 0 b) 11 c) 55 d) array
What is a shell structure examples?
Where static variables are stored in memory in c?
What does == mean in texting?
What is the basic structure of c?
How can I read data from data files with particular formats?
What is scanf_s in c?
What are the applications of c language?
What is the benefit of using #define to declare a constant?
How to draw the flowchart for structure programs?
Why can't I perform arithmetic on a void* pointer?
What is the difference between class and object in c?