Showing and generating an array from a function

I need to generate an array with 25 elements with random numbers from 3-7 and then show them using a function. I keep getting an error on line 20 saying invalid conversion from int to int. What is wrong here with this function and its call?

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
#include <iostream>
#include <time.h>
#include <stdlib.h>
using namespace std;

void showArray ( int a[ ], int size );
int randint(int min, int max);


 int main()
{
    int iseed = time(NULL);
    srand(iseed);

    int a[25];

    cout << "Making an Array of 25 random"
         << " integers from 3 to 7!\n";

    showArray(a[25], 25);

    return 0;
}

void showArray( int a[], int size )
{
    int k, X, j, linecheck;
    for (j = 0; j < 25; j++)
    {
        linecheck++;
        a[j] = randint(3, 7);
        cout << a[j] << ", ";
        if (linecheck == 10)
        {
            cout << endl;
            linecheck = 0;
        }
    }
}

int randint( int min, int max )
{
    return min + rand() % (max - min + 1);
}
Remove the [25] after a on line 20.

You need to pass the whole array, not a single (actually-non-existent) element.
ah i have to take out the brackets as well, makes sense now. originally tried it as a[] and figured the error was there needed to be a number inside the brackets
Topic archived. No new replies allowed.