Dev C++ How To Add Matrices

A Simple C program to add two Matrices. Here we are asking user to input number of rows and columns of matrices and then we ask user to enter the elements of both the matrices, we are storing the input into a multidimensional array for each matrix and after that we are adding corresponding elements of both the matrices and displaying them on. Adding and Subtracting Matrices A matrix can only be added to (or subtracted from) another matrix if the two matrices have the same dimensions. To add two matrices, just add the corresponding entries, and place this sum in the corresponding position in the matrix which results.

Hi again, all---

I'm trying to write a function that will add two matrices and output the resulting matrix.

I've got two matrices already and everything, now i just need to write the function that i can use to call in my switch loop (The program must read two matrices, and the user can then input if they want to add, subtract, or multiply them, and then see their resultant matrix.)

So i've just pasted the function definition i'm trying to use.

In my little command window, it shows me an answer but it's completely wrong!! i don't know how to make a new matrix that adds and i'm kind of lost and frustrated...if someone could give me tips or a skeleton of a function that might work, i'd be much obliged! thanks!

Actually, I'll show you the entire code here, it's incomplete, but as soon as I know how to add (and therefore subtract and multiply) matrices I can fill it all in.

  • 4 Contributors
  • forum 4 Replies
  • 572 Views
  • 5 Years Discussion Span
  • commentLatest Postby adityatandonLatest Post

iamthwee1,547

Try doing it bit by bit and not all at one time.

Placing a few couts here and there should help debugging.

Matrices En C

I'd probably create three matrices. One from matrix one, another for the second matrix and a third for where the result will be stored.

Dev C++ How To Add Matrices Worksheet

Dev c++ how to add matrices calculator

How To Solve Matrices

Matrix addition and subtraction is trivial. You may need more time to think about matrix multiplication however, there are so many example already on the net you should have no problem.