write a program to fined second smallest and largest element
in a given series of elements (without sorting)
Answer Posted / nikhil kumar saraf
void main()
{
int a[12],max,min,min2,i;
printf("enter values");
for(i=0;i<10;i++)
scanf(%d,&a[i]);
max=a[0];
min=a[0];
for(i=0;i<10;i++)
{
if(max<a[i])
max=a[i];
if(min>a[i])
min=a[i];
}
min2=a[0];
for(i=0;i<10;i++)
{
if(min2>a[i] && a[i]!=min)
{
min2=a[i];
}
printf("The second smallest element is:-%d",min2);
printf("The largest element is:-%d",max);
getch();
}
Is This Answer Correct ? | 2 Yes | 4 No |
Post New Answer View All Answers
If errno contains a nonzero number, is there an error?
how to find binary of number?
What is #include cctype?
What is the code for 3 questions and answer check in VisualBasic.Net?
Is c object oriented?
What does return 1 means in c?
Explain what is the difference between null and nul?
What is %g in c?
What is putchar() function?
write a programming in c to find the sum of all elements in an array through function.
Why is python slower than c?
How can you invoke another program from within a C program?
Is using exit() the same as using return?
What is the difference between mpi and openmp?
a c code by using memory allocation for add ,multiply of sprase matrixes