Answer Posted / hardik
#include<stdio.h>
#include<conio.h>
void sort(int,int);
int *arr;
void main()
{
clrscr();
int n,ub,lb=0,i;
printf("ENTER NO OF VALUES U WANT TO ENTER : ");
scanf("%d",&ub);
for(i=0;i<ub;i++)
{
printf("\ENter value : ");
scanf("%d",&arr[i]);
}
sort(lb,ub);
for(i=0;i<ub;i++)
printf("%d\t",arr[i]);
getch();
}
void sort(int lb,int ub)
{
int flag=1,temp,key,i,j;
i=lb; j=ub;
key=arr[i];
if(lb<ub)
{
while(flag)
{
i++;
while(key>arr[i])
i++;
while(key<arr[j])
j--;
if(i<j)
{
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
else
flag=0;
}
temp=arr[lb];
arr[lb]=arr[j];
arr[j]=temp;
sort(lb,j-1);
sort(j+1,ub);
}
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Where are the auto variables stored?
How can you access memory located at a certain address?
Is it better to bitshift a value than to multiply by 2?
What is the use of a semicolon (;) at the end of every program statement?
The number of bytes of storage occupied by short, int and long are a) 2, 2 and 4 b) 2, 4 and 4 c) 4, 4 and 4 d) none
What is difference between function overloading and operator overloading?
What are register variables? What are the advantage of using register variables?
Is it acceptable to declare/define a variable in a c header?
How are portions of a program disabled in demo versions?
Why isn't it being handled properly?
What is the difference between struct and union in C?
What is a buffer in c?
List a few unconditional control statement in c.
What is the -> in c?
What are the types of operators in c?