I am having problems with compiling this code for a multidimensional array. Any help would be appreciated.
#include <cstdlib>
#include <iostream>
using namespace std;
void det2(int[][]);
int main()
{
int rows = 2;
int cols = 2;
int i, j, matrix[rows][cols];
for(i=0; i<rows; i++)
{
cout<<"Enter a Value :";
for(j=0; j<cols; j++)
cin >> matrix[i][j];
}
cout<<endl;
for(i=0; i<rows; i++)
{
for(j=0; j<cols; j++)
cout<< "Values are " << i << "" << j << " is " << matrix[i][j] << endl;
}
det2(matrix);
system("PAUSE");
return 0;
}
void det2(matrix)
{
int x = matrix[0][0]* matrix[1][1] - matrix[1][0]* matrix[0][1];
cout<<x;
}
I am new to arrays so I am not sure what I am doing wrong but here are the error codes:
main.cpp:7: error: multidimensional array must have bounds for all dimensions except the first
main.cpp: In function `int main()':
main.cpp:7: error: too many arguments to function `void det2()'
main.cpp:26: error: at this point in file
main.cpp: At global scope:
main.cpp:31: error: variable or field `det2' declared void
main.cpp:31: error: `int det2' redeclared as different kind of symbol
main.cpp:7: error: previous declaration of `void det2()'
main.cpp:31: error: declaration of `int det2'
main.cpp:7: error: conflicts with previous declaration `void det2()'
main.cpp:31: error: `matrix' was not declared in this scope
main.cpp:32: error: expected `,' or `;' before '{' token
mingw32-make.exe: *** [Objects/MingW/main.o] Error 1
Execution terminated
Compilation Failed. Make returned 2

New Topic/Question
Reply



MultiQuote



|