Help with my code

Can anyone tell me what's wrong with my code?
The function print is supposed to print each element of the array but doesn't seem to work.

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
61
62
63
64
65
66
67
68
69
70
71

#include <iostream>
#include <cstdlib>

using namespace std;

void start (int boxes [10]);
void move (int squares [10], int x, int y, int z);
void add (int arr [10], int first, int last);
void print (int arr [10]);

int main ()
{
    int my_arr [10];

    cout << "The original array is:\n";
    print (my_arr);

    start (my_arr);
    cout << "\n\nThe array after start is:\n";
    print (my_arr);

    move (my_arr, 2, 4, 6);
    cout << "\n\nThe array after move is:\n";
    print (my_arr);

    add (my_arr, 3, 7);
    cout << "\n\nThe array after add is:\n";
    print (my_arr);

    cout << "\n\n";
}


void start (int boxes [10])
{
     int index, count;

     count = 17;
     for (index = 0; index < 10; index++)
     {
         boxes [index] = count;
         count--;
     }
}

void move (int squares [10], int x, int y, int z)
{
     int temp;

     temp = squares [x];
     squares [x] = squares [y];
     squares [z] = squares [y];
     squares [y] = temp;
}

void add (int arr [10], int first, int last)
{
     int m;

     for (m = first; m <= last; m++)
         arr [m]++;
}

void print (int arr [10])
{
     int z;

     for (z = 0; z < 10; z++)
         cout << z << " ";
}
1
2
3
4
5
6
7
8

void print (int arr [10])
{
     int z;

     for (z = 0; z < 10; z++)
         cout << arr[z] << " ";
}

You weren't indexing into the array, you were just printing the index.
Thank you so much.
Topic archived. No new replies allowed.