C++ Error error: invalid types 'double [10][10][double]' for array subscript
<p>I am trying to generate a grid by looping from 0 to 1 in increments of 0.1. The code runs fine when I am incrementing with an integer eg from 0 to 10 in increments of 1 but I am not able to understand whats wrong with this.</p>

<pre><code>#include &lt;iostream&gt;
using namespace std;

int main()
{

double u[10][10];
double dx=0.1, i, j;

for(i=0;i&lt;=1;i+=dx)
for(j=0;j&lt;=1;j+=dx)
{
    u[i][j]=i; // this line gives an error
}
}
</code></pre>