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 atoi and atof in c?
FORMATTED INPUT/OUTPUT functions are a) scanf() and printf() b) gets() and puts() c) getchar() and putchar() d) all the above
What is clrscr ()?
largest Of three Number using without if condition?
What is your stream meaning?
Should a function contain a return statement if it does not return a value?
What is static and auto variables in c?
Explain how are 16- and 32-bit numbers stored?
What is 02d in c?
How do we declare variables in c?
What is a structure in c language. how to initialise a structure in c?
Difference between constant pointer and pointer to a constant.
I completed my B.tech (IT). Actually I want to develop virtual object that which will change software technology in the future. To develop virtual object what course I have to take. can I any professor to help me.
What does != Mean in c?
What are the main characteristics of c language describe the structure of ac program?