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

#include <iostream> #include <cmath> #include <iomanip> using namespace std; int

ID: 3688731 • Letter: #

Question

#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int calcavg(int []);
int variance( int[]);
int main()
{
{int val[14] = { 89,95,75,83,99,54,86,75,92,73,79,75,82,73 };
system("pause");
return 0;
}
int calcavg(int testvals[])
{
  int i;
  int t= 0;
  int a = 0;
for (i = 0; i < 14; i++)
  {
   t = t = testval[i];
   cout << "The total is :" << t << endl;
  }
  cout << endl;
  a = t / 14;
  return;
}
int variance(int testvals[])
{
  int i;
  int t;
  int a;
  int v;
  for (i = 0; i < 14; i++)
{ ERROR RIGHT HERE
   t = t + testvals[];
  }
  cout << endl;
  a = t / 14;
  for (i = 0; i < 14; i++)
  {
   v = v + pow((testvals[i] - a), 2) / 14;
   cout << "The variance is :" << v << endl;
  }
  cout << endl;
  return;
}
return;
}

I'm having an error with my program, its saying it expected a ; which I dont need, How do I get this error to go away so I can run my program? The error is in the beginning just after the for loop

Explanation / Answer

Hi, Below highlighted line is causing an issue.

for (i = 0; i < 14; i++)
{ ERROR RIGHT HERE
   t = t + testvals[];
  }

You have to provide the index of each location of testvals array while iterating. Please find the below and update the same in your code.

for (i = 0; i < 14; i++)
{ ERROR RIGHT HERE
   t = t + testvals[i];
  }

Hope it works for you.