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
Why do we need arrays in c?
Can you write the function prototype, definition and mention the other requirements.
How to write a code for reverse of string without using string functions?
What is a list in c?
What will be the outcome of the following conditional statement if the value of variable s is 10?
Explain how do you declare an array that will hold more than 64kb of data?
What is the use of sizeof () in c?
What is sizeof in c?
What is substring in c?
What are the different types of linkage exist in c?
Explain pointer. What are function pointers in C?
How do I send escape sequences to control a terminal or other device?
Is there a way to jump out of a function or functions?
What's the total generic pointer type?
The number of measuring units from an arbitarary starting point in a record,area,or control block to some other point a) recording pointer b) offset c) branching d) none