Run-Time Check Failure #2 - Stack around the variable 'B' was corrupted
<p>this error keeps coming up yet i dont see a problem with the code (its in c++)
the program is supposed to find the inverse of a 2x2 matrix</p>

<pre><code>#include &lt;iostream&gt;
using namespace std;
int main()
{ 
float d;
float A[2][2],B[2][2];
do
{cout&lt;&lt;"please enter valid parameters in for 11,12,21,22"&lt;&lt;endl;
for(int i=0;i&lt;2;i++)
{ for(int j=0;j&lt;2;j++) {cin&gt;&gt;A[i][j];}}
d=(A[1][1]*A[2][2])-(A[1][2]*A[2][1]);
}while (d==0);
B[1][1]=A[2][2]*(1.0/d);
B[1][2]=A[1][2]*(-1.0/d);
B[2][1]=A[2][1]*(-1.0/d);
B[2][2]=A[1][1]*(1.0/d);
for(int k=0;k&lt;2;k++)
{
for(int h=0;h&lt;2;h++) {cout&lt;&lt;B[k][h]&lt;&lt;" ";}
cout&lt;&lt;endl;
}
return 0;
}
</code></pre>
