How would you write qsort?
Answer / 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 |
write a program to generate 1st n fibonacci prime number
m=++i&&++j(||)k++ printf("%d"i,j,k,m)
What is the process to generate random numbers in c programming language?
What's the total generic pointer type?
a parameter passed between a calling program and a called program a) variable b) constant c) argument d) all of the above
Once I have used freopen, how can I get the original stdout (or stdin) back?
how to calculate the time complexity of a given algorithm? pls give exaples..mainly for the coplexities such as O(log n),O(n log n)...
What are static functions?
What is typedf?
What is the best style for code layout in c?
What is #line used for?
How do we declare variables in c?