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

Answer Posted / sachin tyagi

void main()
{
int a[12],max,min1.min2,max2,i,temp;
printf("enter valu");
for(i=0;i<11;i++)
scanf(%d,&a[i]);
max=a[0];
min1=a[0];
for(i=1;i<11;i++)
{
if(max<a[i])
max=a[i];
if(min1>a[i];
min1=a[i]
}
for(i=1;i<11;i++0
{
if((max2>a[i])&&(max2!=max){
max2=a[i];
}
if((min2<a[i])&&(min2!=min1))
{
min2=a[i];}

print("small is %d and large is %d", min2,max2);
}

Is This Answer Correct ?    15 Yes 13 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of a semicolon (;) at the end of every program statement?

748


Why doesnt this code work?

607


What is cohesion and coupling in c?

574


Explain what math functions are available for integers? For floating point?

597


Which of these functions is safer to use : fgets(), gets()? Why?

621






Explain how do you determine a file’s attributes?

584


7-Given an index k, return the kth row of the Pascal's triangle. For example, when k = 3, the row is [1,3,3,1]. For reference look at the following standard pascal’s triangle.

2206


What is the use of define in c?

581


What are 'near' and 'far' pointers?

603


What are keywords c?

587


how can I convert a string to a number?

583


What are the string functions? List some string functions available in c.

592


What is operator promotion?

615


Ow can I insert or delete a line (or record) in the middle of a file?

560


When should you use a type cast?

574