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 are the scope of static variables?
How to delete a node from linked list w/o using collectons?
Explain about block scope in c?
Explain what is the heap?
How do you convert strings to numbers in C?
How to write a multi-statement macro?
why return type of main is not necessary in linux
Write a program of advanced Fibonacci series.
What is volatile, register definition in C
How pointer is different from array?
Is it better to use a macro or a function?
Can you pass an entire structure to functions?
How #define works?
What is context in c?
How the c program is executed?