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 getche() function?

609


Sir i need notes for structure,functions,pointers in c language can you help me please

1945


What is #define in c?

622


Is return a keyword in c?

598


Why do we need functions in c?

561






What is the explanation for cyclic nature of data types in c?

648


What is the difference between printf and scanf )?

595


Explain what is a program flowchart and explain how does it help in writing a program?

649


What is the concatenation operator?

614


What is the benefit of using const for declaring constants?

588


Differentiate between a for loop and a while loop? What are it uses?

675


the maximum length of a character constant can be a) 1 character b) 8 characters c) 256 chaacters d) 125 characters

1802


How would you rename a function in C?

622


What are multidimensional arrays?

656


How does selection sort work in c?

623