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 main difference between calloc () and malloc ()?
How do I convert a string to all upper or lower case?
What does the format %10.2 mean when included in a printf statement?
Why is python slower than c?
What is cohesion and coupling in c?
What is the heap?
What is quick sort in c?
Write a function that will take in a phone number and output all possible alphabetical combinations
What are the features of the c language?
Draw a flowchart to produce a printed list of all the students over the age of 20 in a class .The input records contains the name and age of students. Assume a sentinel value of 99 for the age field of the trailer record
What is difference between arrays and pointers?
Can an array be an Ivalue?
Is there a built-in function in C that can be used for sorting data?
When is a “switch” statement preferable over an “if” statement?
How can I call a function with an argument list built up at run time?