Question: // // main.cpp // Shell Sort // // NO OUTPUTTTTTTTTTTTTTTTT #include #include #include #include using namespace std; int rand(); // function to generate random number

//

// main.cpp

// Shell Sort

//

// NO OUTPUTTTTTTTTTTTTTTTT

#include

#include

#include

#include

using namespace std;

int rand(); // function to generate random number

void sort(int a [], int n); // function to sort the array

void display(int a[]); // function to display the array

int main()

{

int array[25];

srand(time(NULL)); //ERRORRRRRRRRRRRRRRRRRR

for(int i= 0; i < 20; i++)

{

array[i] = rand();

}

sort(array, 20);

display(array);

return 0;

}

int rand()

{

return(1 + rand() % 50); // return random number from 1 to 50 // ERRORRRRRRRRRRRRR

}

void sort(int a[], int n)

{

int temp;

for(int x = 0; x < n; x++)

{

for(int i = 0; i < n; i++)

{

if(a[i] > a[i + 1])

{

temp = a[i];

a[i] = a[i + 1];

a[i + 1] = temp;

}

}

}

}

void display(int a[])

{

for(int c = 0; c < 20; c++)

{

cout << a[c] << endl;

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!