write a program to fined second smallest and largest element
in a given series of elements (without sorting)

Answer Posted / vadivel t

#include<stdio.h>

void main()
{
int a[10] = {5,4,1,7,3,0,8,23,12,24};
int Lcount = 0, Gcount = 0, i, j;

for(i = 0; i<10; i++)
{
Gcount = 0;
Lcount = 0;
for(j = 0; j<10; j++)
{
if(a[i] > a[j])
{
Gcount++;
Lcount++;
}
}
if(Gcount == 8)
{
printf("The second largest no is: %
d \n", a[i]);
}
if(Lcount == 1)
{
printf("The second smallest no is: %
d \n", a[i]);
}
}
_getch();
}

Is This Answer Correct ?    2 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

State the difference between realloc and free.

635


Write a program to reverse a linked list in c.

647


How was c created?

589


What is wrong with this program statement?

610


a direct address that identifies a location by means of its displacement from a base address or segment a) absolute address b) relative address c) relative mode d) absolute mode

659






What is scanf () in c?

662


Differentiate abs() function from fabs() function.

597


Explain do array subscripts always start with zero?

761


Is printf a keyword?

762


What is structure data type in c?

572


what is a function method?give example?

1914


Explain how do you sort filenames in a directory?

608


What are actual arguments?

647


What are directives in c?

548


What is typedef?

678