error: expected identifier or ‘(’ before ‘}’ token }
<p>I know this question was already asked, and I checked all the previous answers but still cannot find the error. The program is not finished yet so the logic is incomplete, I just want to run and check what I have so far. </p>

<pre><code>#include &lt;math.h&gt;
#include &lt;stdio.h&gt;
#include &lt;omp.h&gt;

int a[100][100];

int countNeighbors(int x, int y){

    int count = 0;
    int i,j;
    for (i = x-1; i &lt;= x+1; i++)
        for (j = y-1; i &lt;= y+1; j++)
            if (a[x][y] == 1) count++;

    return count;
}

int main (int argc, const char* argv[]) {

    int n, i, j, count;

    printf("Enter grid dimension:");
    scanf("%d",&amp;n);   

// Initializing the array with random values
    srand (time(NULL));
    for (i=0;i&lt;n;i++)
        for(j=0;j&lt;n;j++)
            a[i][j] = rand() % 2;


    for (i=0;i&lt;n;i++){
        printf("\n");
        for(j=0;j&lt;n;j++)
            printf("%d",a[i][j]);
    }

    for (i = 1; i &lt; n-1; i++)
        for (j = 1; j &lt; n-1; j++){
            count = countNeighbors(i,j);
            if (a[i][j] == 1){
                if (count &gt;= 4 || count &lt;=1) a[i][j] = 0;
                else a[i][j] = 1;
            }   
            else if (count == 3) a[i][j] = 1;   
        }


    for (i=0;i&lt;n;i++){
        printf("\n");
        for(j=0;j&lt;n;j++)
            printf("%d",a[i][j]);
    }


}
</code></pre>