I am currently working with arrays and moving around the data from array to array, however, that isnt the issue the issue is within my void functions more specifically my for loops i dont know why it won't compile when it looks correct to me and I see in my teacher's note that it is possible to declare an integer in a for loop within a void function but still receiving errors.
Error: exercise11.cpp:49:12: error: ânâ was not declared in this scope for(i=0; n=11; n
Code:
#include <iostream>
#include <string>
#include <cmath>
#include <cctype>
#include <iomanip>
#include <fstream>
using namespace std;
const int MAX = 20;
void reformat(double[], double[], int);
void sum(double[], double[], int);
int main()
{
double input[MAX];
double newarray[MAX];
cout << fixed << right << setprecision(5);
cout << "Morgan Kiger Lec#1002 Lab#1005 Exercise #11" << endl << endl;
for (int i=0; i<MAX; i++)
{
cin >> input[i];
}
reformat(input, newarray, MAX);
sum(input, newarray, MAX);
return 0;
}
void reformat(double input[], double newarray[], int MAX)
{
for(int i=0; int n=10; n<MAX; i++, n++)
{
newarray[n] = input[i]*2;
}
for(i=0; n=11; n<MAX; i++, n++)
{
newarray[i] = pow(input[n], 0.3);
}
return;
}
void sum(double input[], double newarray[], int MAX)
{
double sum1;
double sum2;
cout << "Input Array" << setw(5) << "2nd Array" << endl;
for(int i=0; i<MAX; i++)
{
sum1 = input[i] + sum1;
}
for(int i=0; i<10; i++)
{
sum2 = newarray[i] + sum2;
}
for(int i=0; i<MAX; i++)
{
cout << input[i] << setw(5) << newarray[i] << endl;
}
cout << "sum of input valves = " << sum1 << endl;
cout << "sum of 1st 10 values in changed array = " << sum2 << endl;
return;
}