C programming how to complete the main in this class include

C programming:
how to complete the main in this class?


#include \"records.h\"

quicksort(int a[], int l, int r){ int v, i, j, t;
if (r>l) {

v=a[r]; i=l-1; j=r;
for (;;){

while (a[++i]<v); while (a[--j]>v); if (i>=j) break; t=a[i]; a[i]=a[j]; a[j]=t;

}
t=a[i];
a[i]=a[r];
a[r]=t;
quicksort(a, l, i-1); quicksort(a, i+1, r);

} }



main(){
}


in records.h i have:
int records[200][7]={{47,5061,6392,855,3458,7367,5948},{61,2479… .. .. ..

Solution

#include<stdio.h>
void quicksort(int a[], int l, int r)
{
int v, i, j, t;
if (r>l)
{
v=a[r]; i=l-1; j=r;
for (;;){
while (a[++i]<v); while (a[--j]>v); if (i>=j) break; t=a[i]; a[i]=a[j]; a[j]=t;
}
t=a[i];
a[i]=a[r];
a[r]=t;
quicksort(a, l, i-1); quicksort(a, i+1, r);
} }


main(){
int x[20],size,i;

printf(\"Enter size of the array: \");
scanf(\"%d\",&size); //takes user size for the elements

printf(\"Enter %d elements: \",size); //prompts the user to enter size elements
for(i=0;i<size;i++)//loops until the ,mentioned size elements are entered by the user
scanf(\"%d\",&x[i]);//takes each element from the user

quicksort(x,0,size-1); //quicksort function is called taking array 0 and size as parameters

printf(\"Sorted elements: \");
for(i=0;i<size;i++)
printf(\" %d\",x[i]);//displays all elements in the sorted array

return 0;}

C programming: how to complete the main in this class? #include \
C programming: how to complete the main in this class? #include \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site