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
State the difference between realloc and free.
Write a program to reverse a linked list in c.
How was c created?
What is wrong with this program statement?
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
What is scanf () in c?
Differentiate abs() function from fabs() function.
Explain do array subscripts always start with zero?
Is printf a keyword?
What is structure data type in c?
what is a function method?give example?
Explain how do you sort filenames in a directory?
What are actual arguments?
What are directives in c?
What is typedef?