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
Where in memory are my variables stored?
Explain what are its uses in c programming?
Which node is more powerful and can handle local information processing or graphics processing?
‘ C’ PROGRAME TO SHOW THE TYPE OF TRANGLE BY ACCEPTING IT’S LENGTH .
How do you sort filenames in a directory?
Can you write the function prototype, definition and mention the other requirements.
Is it better to use a macro or a function?
Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal. [ I gave the obvious solution of taking % 10 and / 10, which gives us the decimal value in reverse order. This requires an array since we need to print it out in the correct order. The interviewer wasn't too pleased and asked me to give a solution which didn't need the array ].
What does the error 'Null Pointer Assignment' mean and what causes this error?
Under what circumstances does a name clash occur?
Is calloc better than malloc?
What is the argument of a function in c?
Explain how can I prevent another program from modifying part of a file that I am modifying?
Explain spaghetti programming?
What are the 5 types of inheritance in c ++?