My program runs. However, it seems that the do-while loop won't loop. This is because the output always declare "...was obtained after 1 iterations". I mean it should take more than 1 iterations. I would like to ask for help for I am facing a brick wall right now. Thanks!
#include <iostream>
#include <iomanip>
#include <cmath>
#include <fstream>
#include <string>
using namespace std;
int main()
{
   int i,j,n,iter1=0,iter2=0;
   double L,t,q,E,v,h,D,error,e;
   cout << "\nUse length, L (m): ";
   cin >> L;
   cout << "\nUse thickness, t (m): ";
   cin >> t;
   cout << "\nUse uniform load, q (N/m^2): ";
   cin >> q;
   cout << "\nUse Young's modulus, E (N/m^2): ";
   cin >> E;
   cout << "\nUse Poisson's ratio, v: ";
   cin >> v;
   D=(E*pow(t,3))/(12*(1-pow(v,2)));
   cout << "\nUse uniform interval, n: ";
   cin >> n;
   double u[n+1][n+1],r[n+1][n+1],w[n+1][n+1];
   h = L/n;
   cout << "\nUse tolerance, e: ";
   cin >> e;
   //PERFORM THE ITERATIONS!
   cout << "* * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n" ;
   cout.precision(5);
   cout.setf(ios::fixed);
   for (i=0;i<=n;i++)
   for (j=0;j<=n;j++)
   {
      u[i][j]=0;
      r[i][j]=0;
      w[i][j]=0;
   }
  //Set the boundary conditions
  for (i=0;i<=n;i++)
  {
      u[i][0]=0;
      u[i][n]=0;
      u[0][i]=0;
      u[0][i]=0;
  }
  //Solving for the u-matrix
do
{
    error=0;
    for (i=0;i<n;i++)
    for (j=0;j<n;j++)
    {
        r[i][j]=0.25*(u[i-1][j]+u[i+1][j]+u[i][j-1]+u[i][j+1]-4*u[i][j]-pow(h,2)*(q/D));
        u[i][j]+=r[i][j];
    }
    iter1++;
    if (abs(r[i][j])>error)
    error = abs(r[i][j]);
}
while (error>e);
//Solving for the w-matrix
do
{
    error=0;
    for (i=0;i<n;i++)
    for (j=0;j<n;j++)
    {
        r[i][j]=0.25*(w[i-1][j]+w[i+1][j]+w[i][j-1]+w[i][j+1]-4*w[i][j]-pow(h,2)*(u[i][j]));
        w[i][j]+=r[i][j];
    }
    iter2++;
    if (abs(r[i][j])>error)
    error = abs(r[i][j]);
}
while (error>e);
//RESULTS!
cout << "\nThe matrix of deflection w was obtained after " << iter2 << " iterations" << endl;
cout << "\n(The matrix of variable u was obtained after " << iter1 << " iterations" << endl;
cout << "\n";
cout << "\nFor the matrix of deflection w, open the generated Excel file.\n";
return 0;
}
 
     
    