### Matrix Problem

closed account (owCSLyTq)
Hello, i'm having trouble with the cofactors while compiling. can you tell me the problem?
 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190`` ``````#include using namespace std; int main() { int add(int matA[3][3],int matB[3][3]); int sub(int matA[3][3],int matB[3][3]); int mul(int matA[3][3],int matB[3][3]); int Tr(int matA[3][3]); int det(int matA[3][3]); int Trans(int matA[3][3]); int cofactor(int mat[3][3]); int inv(int matA[3][3]); int solve(int matA[3][3],int b[3]); int x,A[3][3],B[3][3],b[3],C[3][3]; cout<<"This program allows you to perform certain matrix and vector operations on a 3x3 matrix"<>x; switch(x){ case 1: { cout<<"enter matrix 1"; cin>>A[3][3]; cout<<"enter matrix 2"; cin>>B[3][3]; cout<<"the sum is "<>A[3][3]; cout<<"enter matrix 2"; cin>>B[3][3]; cout<<"the difference is"<>A[3][3]; cout<<"enter matrix 2"; cin>>B[3][3]; cout<<"the product is"<>A[3][3]; cout<<"the trace is "<>A[3][3]; cout<<"the determinant is"<>A[3][3]; cout<<"The transpose is"<>A[3][3]; cout<<"The adjoint is"<>A[3][3]; cout<<"The inverse is"<>A[3][3]; cout<<"Enter your vector b"; cin>>b[3]; cout<<"The solution is"<
Does `return;` in your cofactor method make sense? SHould their be a semicolon after return if you're trying to return a value?
Last edited on
 i'm having trouble while compiling

A compiler error? What error?
closed account (owCSLyTq)

1>g:\matrix project.cpp(75): error C2664: 'Trans' : cannot convert parameter 1 from 'int' to 'int [][3]'

the return; in cofactor and the int main() above are causing the errors when debugging and i don't see how to solve it.
Last edited on
You claim that cofactor() returns an int. It probably should not. Define it as:
`void cofactor( int matB[3][3], int matC[3][3] )`

Then you obviously need a int [3][3] that you pass to cofactor() and Trans().

Do not declare functions inside main(). Do it before main().
closed account (owCSLyTq)
what do you mean that "Then you obviously need a int [3][3] that you pass to cofactor() and Trans()."

Thanks :)
Lets ignore that for now.

Given that you have `int A[3][3];`, what does this piece of your code do?
`cin>>A[3][3];`
closed account (owCSLyTq)
It's a 3x3 array to find matrix A.
The `cin>>A[3][3];` ?

That statement extracts one integer from input stream object 'cin' and stores it into memory location at A+9. Too bad the matrix referred to by name 'A' covers only locations from A to A+8. We have no idea what is in A+9, i.e. what does that statement accidentally overwrite.

closed account (owCSLyTq)
I wrote another program today. But now I can find a solution to how to solve the linear problem. It keep saying break continue.
Topic archived. No new replies allowed.