Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

( Someone skilled in Fortan ) I wrote up some code in C++ and I am having a bit

ID: 3588226 • Letter: #

Question

( Someone skilled in Fortan )

I wrote up some code in C++ and I am having a bit of a hard time translating it into Fortan 90 as I am a beginner CS student. I have do all of the work below. I simply ask if someone can translate it to Fortan 90. I understand logic fully in C++ so I do not need an explanation just help changing it into Fortran 90. Thanks!

int i, j, k = 0;

   int n = 3; //number of observations

   float x[3] = { 3, 4, 5 }; // stores x data points
   float y[3][3] = { {5, 10, 1}, {0,0,0}, {0,0,0} }; // divided difference table. First col is y value

  
   // compute newton's divided difference formula and store it array
   for (i = 1; i < n; i++)
   {
       k = i;
       for (j = 0; j<n - i; j++)
       {
           y[i][j] = (y[i - 1][j + 1] - y[i - 1][j]) / (x[k] - x[j]);
           k++;
       }
   }

Explanation / Answer

int i, j, k = 0;

   int n = 3; //number of observations

   float x[3] = { 3, 4, 5 }; // stores x data points
   float y[3][3] = { {5, 10, 1}, {0,0,0}, {0,0,0} };

  
   for (i = 1; i < n; i++)
   {
       k = i;
       for (j = 0; j<n - i; j++)
       {
           y[i][j] = (y[i - 1][j + 1] - y[i - 1][j]) / (x[k] - x[j]);
           k++;
       }
   }