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
What is the value of uninitialized variable in c?
what are # pragma staments?
What is clrscr in c?
Why shouldn’t I start variable names with underscores?
how should functions be apportioned among source files?
What does sizeof function do?
Can we increase size of array in c?
Why we use int main and void main?
What does do in c?
Is it acceptable to declare/define a variable in a c header?
What is the translation phases used in c language?
What is a structure in c language. how to initialise a structure in c?
How are structure passing and returning implemented?
What is a sequential access file?
What does the characters “r” and “w” mean when writing programs that will make use of files?