how to find the kth smallest element in the given list of
array elemnts.

Answer Posted / ruchi

#include<stdio.h>
#include<conio.h>
int main()
{
int a[10],i,j,n,temp;
printf("\nEnter the number of elements int he array ");
scanf("%d",&n);
printf("\nEnter the elements ");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
printf("\nThe smallest element is ");
for(i=0;i<n;i++)
{
printf("%d\n",a[i]);
break;
}
getch();
}

Is This Answer Correct ?    12 Yes 28 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the value of uninitialized variable in c?

800


what are # pragma staments?

1820


What is clrscr in c?

891


Why shouldn’t I start variable names with underscores?

843


how should functions be apportioned among source files?

873


What does sizeof function do?

882


Can we increase size of array in c?

717


Why we use int main and void main?

801


What does do in c?

795


Is it acceptable to declare/define a variable in a c header?

885


What is the translation phases used in c language?

841


What is a structure in c language. how to initialise a structure in c?

840


How are structure passing and returning implemented?

781


What is a sequential access file?

872


What does the characters “r” and “w” mean when writing programs that will make use of files?

1187