the program is supposed to find the sum of 10 integer numbers stored in an array but i'm having this error:
[Error] invalid types 'int[int]' for array subscript.
this is my program:

#include<iostream>
using namespace std;
void readarray(int array[][30], int rows)
    {
        int i=1;
        cout<<"Enter 30 Numbers into an array:"<<endl;
        for (int j=0;j<10;j++)
                {
            cout<<"Number "<<i++<<" : ";
            cin>>array[i][j];
        }
    }
int main()
{
    int sum=0,array;
    int x[30][30];
    readarray(x,30);
    if (array[30]%2==0)
        {
            sum+=array[30];
        }

    cout<<"Sum of even numbers="<<sum<<endl;
    cout<<"-----------------------------------"<<endl;
    return 0;
}

You are accessing the array as a 1 dimentional one, but you have defined it as a 2 dimensional array. Your readarray() method is only assigning numbers to array[1][0...9], so your sum loop is wrong.

You are inserting 10 numbers to your array.
int array is a uninitialized variable, but is accessed as an array if(array[30]%2==0)
Please be more specific on what you want to do with this console app.

@admir192 ... did you miss this first line by the OP?

"the program is supposed to find the sum of 10 integer numbers stored in an array ..."

It seems the OP has either figured out the problem from the good clue provided by Dani's @rubberman ... or ... perhas has abandoned this forum?

The only further hint to the OP ...might be to plainly state ...
that your problem spec's seem to clearly enough direct you
to use just a 1-D array to hold 10 integers.

This is such a common beginning C++ student type problem that some years ago I put this link up for students to see ... (it also shows a 'student way' to take in valid integers so that the running program will not crash on invalid data input.)

http://developers-heaven.net/forum/index.php/topic,2019.0.html

Defined the array 1 to 2 array dimentional .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.