Write a function called matrixAdd1 that adds 1.0 to each element of a matrix of doubles . An initial function skeleton is provided --- your job is to write the body of the function. Note that the matrix M has numRows rows and numCols columns, which are passed as parameters to the function. The function should NOT return a value , and should not use cout nor cin.
Not quite. What you stated sets the value at M[r][c] to be equal to the value one diagonal over; in other words, M[1][1]=M[2][2]. What you want to do is something like this:
M[r][c] += 1.0;
Now, since technically 1.0 is the same as 1 in regards to addition (minus the .000000001 decimal difference that tends to happen when you do anything with floating-points), you could simply write it as this: