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

List the difference between a "copy constructor" and a "assignment operator"?

583


Why is c faster?

592


What is actual argument?

591


Explain what are linked list?

626


What is the use of sizeof () in c?

558






What is wrong with this statement? Myname = 'robin';

822


Difference between Shallow copy and Deep copy?

1572


Which is better oop or procedural?

634


write a c program to do the following: a) To find the area of a triangle. b) To convert the temperature from Fahrenheit to Celsius. c) To convert the time in hours : minutes : seconds to seconds.

1518


Function which gives a pointer to a binary trees const an integer value at each code, return function of all the nodes in binary tree.?

630


Where can I get an ansi-compatible lint?

642


Are the outer parentheses in return statements really optional?

577


count = 0; for (i = 1;i < = 10; i++);count = count + i; Value of count after execution of the above statements will be a) 0 b) 11 c) 55 d) array

679


Tell me is null always defined as 0(zero)?

674


What is static and auto variables in c?

567