write a program to fined second smallest and largest element
in a given series of elements (without sorting)

Answer Posted / raj

#include <stdio.h>


void main()
{
int i, ar[] ={15,22,122,15,6,12};
int a,b= 0,c,ta ,tb, tc;
a =ar[0];
b = ar[1];

for (i = 0; i < 6 ;i++)
{
if(a > ar[i])
{
b = a;
a = ar[i];
}
else if(b > ar[i])
{
b = ar[i];
}
}

printf("\n %d ",b);
}

Is This Answer Correct ?    3 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is indirection in c?

612


How will you declare an array of three function pointers where each function receives two ints and returns a float?

767


Why is c called c not d or e?

600


Explain main function in c?

614


Can you please explain the difference between malloc() and calloc() function?

609






What are the two forms of #include directive?

632


What is a c token and types of c tokens?

579


void main(int n) { if(n==0) return; main(--n); printf("%d ",n); getch(); } how it work and what will be its output...............it any one know ans plz reply

2208


What is memory leak in c?

623


Describe the order of precedence with regards to operators in C.

626


What are pointers? What are stacks and queues?

570


Difference between goto, long jmp() and setjmp()?

694


What is the difference between exit() and _exit() function?

592


How do you use a 'Local Block'?

712


What are the data types present in c?

617