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 is actual argument?
What are the properties of union in c?
Why do we use return in c?
How can you restore a redirected standard stream?
Describe the steps to insert data into a singly linked list.
What is the use of bit field?
Explain how do you determine whether to use a stream function or a low-level function?
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
Give the rules for variable declaration?
What is the purpose of the preprocessor directive error?
Explain what is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?
write a C program:There is a mobile keypad with numbers 0-9 and alphabets on it. Take input 0f 7 keys and then form a word from the alphabets present on the keys.
What is the purpose of the statement: strcat (S2, S1)?
Explain how can I right-justify a string?
while loop contains parts a) initialisation, evalution of an expression,increment /decrement b) initialisation, increment/decrement c) condition evalution d) none of the above