-Ask user to give size of array

-Then asks again if user wants to enter the array or generate random numbers

-if user wants to enter the numbers to fill array, then ask number and receive the value to fill the array.

--------------------------------------------------------

I'm trying to figure out a couple of things. For one, what kind of statement I should use. For instance, if/else do/while etc. when asking the user for entering an array or using a rand # generator. I thought maybe I should use a switch statement, but it wasn't working very well.

Also, I am running into some odd errors after execution. The bubble sort organizes the numbers, but it creates a whole bunch of random numbers at the end.

For example:

**Enter size of array: 5**

1:5

2:4

3:3

4:2

5:1

The sorted values are:

1 2 3 4 5 23934 39204302 34902302 20340234 3939 etc.

1:5

2:4

3:3

4:2

5:1

The sorted values are:

1 2 3 4 5 23934 39204302 34902302 20340234 3939 etc.

Here is my code so far...

#include <iostream> #include <cstdlib> #include <ctime> using namespace std; void sortArray(int [], int); void showArray(int [], int); int main() { unsigned seed = time(0); srand(seed); int values[1000]; int size; cout << "Enter size of array: "; cin >> size; for(int i=0; i < size; i++) { cout << i+1 << ":"; cin >> values[i]; } sortArray(values,100); cout << "The sorted values are:\n"; showArray(values,100); system("pause"); return 0; } void sortArray(int array[], int size) { bool swap; int temp; do { swap = false; for(int count = 0; count < (size-1); count++) { if(array[count] > array[count+1]) { temp = array[count]; array[count] = array[count+1]; array[count+1] = temp; swap = true; } } } while(swap); } void showArray(int array[], int size) { for(int count = 0; count < size; count++) cout << array[count] << " "; cout << endl; }

Thanks