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 are the uses of a pointer?

770


What is structure of c program?

693


What are the different categories of functions in c?

764


How to write c functions that modify head pointer of a linked list?

631


How can I recover the file name given an open stream or file descriptor?

699






How do you write a program which produces its own source code as output?

703


Explain how can you tell whether two strings are the same?

675


i have a written test for microland please give me test pattern

2302


What is a pointer in c plus plus?

796


Explain why can’t constant values be used to define an array’s initial size?

965


What is the purpose of clrscr () printf () and getch ()?

689


What are the 4 data types?

676


How can I find out if there are characters available for reading?

731


Explain what does the function toupper() do?

734


What are the features of the c language?

726