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
Does c have an equivalent to pascals with statement?
What are the string functions? List some string functions available in c.
Who is the founder of c language?
what is the syallabus of computer science students in group- 1?
Hai what is the different types of versions and their differences
How can I manipulate individual bits?
What is ctrl c called?
List the difference between a 'copy constructor' and a 'assignment operator' in C?
Explain what would happen to x in this expression: x += 15; (assuming the value of x is 5)
How do we open a binary file in Read/Write mode in C?
How is a macro different from a function?
Is it possible to have a function as a parameter in another function?
What are the different types of errors?
What is void main ()?
in case any function return float value we must declare a) the function must be declared as 'float' in main() as well b) the function automatically returned float values c) function before declared 'float' keyword d) all the above