0
2D array
Program that ask the user row and column size of a 2d array and asks the user for the elements. Write the total of the sum of each row multiplied with the row number. Example: The elements of array is 1-9 with row being 3 and column being 3. Output would be : 1 2 3 4 5 6 7 8 9 Total : 108 Explanation: 1 2 3 ---> (1+2+3) * 1 = 6 4 5 6 ---> (4+5+6) * 2 = 30 7 8 9 ---> (7+8+9) * 3 = 72 // 6+30+72 Total: 108 I already did the most part and is struggling on the multiply part.. https://code.sololearn.com/c9fNwmJH9AbF/?ref=app
3 Answers
+ 2
Multiply <sum> by ( <i> + 1 ) when adding row wise sum to <total> at line 13 (plus 1 because <i> began with zero)
total += sum * ( i + 1 );
+ 1
Thanks man Ipang.. i dont know why i didn't realize that answer.. like i could have swear i did it or just didn't realize it..