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 is c++ used for today?
What is pointer & why it is used?
What is scope of variable in c?
What does main () mean in c?
What is a shell structure examples?
What are the different categories of functions in c?
What is 1d array in c?
What is a pointer in c?
What is the condition that is applied with ?: Operator?
hi friends how r u as soon in satyam my interview is start but i m very confusued ta wat i do plz help me frndz wat can i do plz tell me some question and answers related with "C" which r asked in the interview .
What is void main () in c?
What is the difference between typedef struct and struct?
What is the difference between mpi and openmp?
State two uses of pointers in C?
Explain about the constants which help in debugging?