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
Is flag a keyword in c?
How can I send mail from within a c program?
Explain is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?
What is calloc() function?
How many types of operator or there in c?
What happens if header file is included twice?
Can you please compare array with pointer?
Write a program of advanced Fibonacci series.
Is c still relevant?
What is the difference between arrays and pointers?
what is uses of .net
1) There is a singing competition for children going to be conducted at a local club. Parents have been asked to arrive at least an hour before and register their children’s names with the Program Manager. Whenever a participant registers, the Program Manager has to position the name of the person in a list in alphabet order. Write a program to help the Program Manager do this by placing the name in the right place each time the Program Manger enters a name. 2) the Event Manager has to send participants to the stage to perform in the order in which they registered. Write a program that will help the Event Manager know who to call to the stage to perform. The Logic should be in Data Structures
How is a macro different from a function?
Explain null pointer.
What is external variable in c?