My question is: I have a matrix. I need to calculate the corresponding Fibonacci number to each entry in that matrix, and return those values into another matrix. I keep getting a C2109 "Subscript requires array or pointer type", and I know where it's coming from, and I know what it means, but I don't know how to
- fix it
- make my code work.
Right now, it doesn't do anything. I'm not sure if I'm even returning any value from my Fibonacci function, or calling it correctly in my main function. I've modified it from what it originally was. Here's my new code:
const int row1 = 3;
const int col1row2 = 3;
const int col2 = 3;
int fibonacci (int [][col2]);
void main()
{
int p[row1][col2], f [row1][col2];
int sum;
input (a,b);
cout<<"The Fibonacci Matrix is: ";
cout<<fibonacci(p);
for ( int i = 0; i < row1; i++)
{
for ( int j = 0; j < col2; j++)
{
sum = f[i][j];
f[i][j] = fibonacci(p);
}
}
cout<<endl;
}
int fibonacci (int z[][col2])
{
int fib [100] = {0 , 1};
int sum = 0;
for ( int m = 2; m < 100; m++)
{
sum = fib[m-1] + fib[m-2];
fib[m] = sum;
}
return sum;
cout<<endl;
}
Any help is appreciated!