random numbers in an array

I'm having trouble putting random numbers into an array.
this is what I have so far.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
 #include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

void showArray(int [], int);
void sortArray(int [], int);

int main()
{
	const int SIZE = 60,


	        srand((unsigned int)time(0));

        for (int count = 0; count < SIZE; count++)
       
		{
			int value[SIZE] = {1 + rand()%100};
        }


	cout << "The unsorted values are:\n";
	showArray(values, SIZE); // compiler says values is undefined. 

	sortArray(values, SIZE);

	cout << "The sorted values are:\n";
	sortArray(values, SIZE);
	return 0;
}

void sortArray(int array [], int size)
{
	int temp;
	bool swap;

	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;
}
Last edited on
There is no such thing in your code called "values." There is an array called value, yes, but nothing called values.
Topic archived. No new replies allowed.