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
What are 3 types of structures?
What is meant by gets in c?
What is dynamic dispatch in c++?
How do shell structures work?
What is console in c language?
State two uses of pointers in C?
Why is c not oop?
what is a constant pointer in C
What is structure in c language?
What is the difference between local variable and global variable in c?
What is the difference between near, far and huge pointers?
Tell me the use of bit field in c language?
Where can I get an ansi-compatible lint?
What is the use of a static variable in c?
Do you know the difference between malloc() and calloc() function?