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
Write a program to print factorial of given number without using recursion?
Why functions are used in c?
Why is void main used?
Why is sizeof () an operator and not a function?
What is auto keyword in c?
What is the right type to use for boolean values in c? Is there a standard type?
in case any function return float value we must declare a) the function must be declared as 'float' in main() as well b) the function automatically returned float values c) function before declared 'float' keyword d) all the above
The number of measuring units from an arbitarary starting point in a record,area,or control block to some other point a) recording pointer b) offset c) branching d) none
Explain what are compound statements?
Explain what is wrong in this statement?
i got 75% in all semester am i eligible for your company
What is the description for syntax errors?
What is difference between class and structure?
which of the following statement is wrong a) mes=123.56; b) con='T'*'A'; c) this='T'*20; d) 3+a=b;
What are file streams?