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
disply the following menu 1.Disply 2.Copy 3.Append; as per the menu do the file operations 4.Exit
Write an algorithm for implementing insertion and deletion operations in a singly linked list using arrays ?
What is context in c?
How can a program be made to print the name of a source file where an error occurs?
about c language
Can 'this' pointer by used in the constructor?
Explain what is dynamic data structure?
When is the “void” keyword used in a function?
What are the types of arrays in c?
What is the use of clrscr?
Explain output of printf("Hello World"-'A'+'B'); ?
Which are low level languages?
what is the differnce between programing langauge and tool? is sas is a programing langauge r tool?
What does the error message "DGROUP exceeds 64K" mean?
Write a program to generate random numbers in c?