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
Are there namespaces in c?
Are local variables initialized to zero by default in c?
What is the best way to store flag values in a program?
number of times a digit is present in a number
c program to compute AREA under integral
How do I send escape sequences to control a terminal or other device?
printf(), scanf() these are a) library functions b) userdefined functions c) system functions d) they are not functions
How to throw some light on the b tree?
Explain what are multidimensional arrays?
What is use of integral promotions in c?
What is oops c?
How do you use a 'Local Block'?
How is a structure member accessed?
What is adt in c programming?
What are c preprocessors?