Java C++, dealing with matrix sum

Programming
Tutor: None Selected Time limit: 1 Day

int i,j;

      for(i=0;i<4;i++)

      {

         for(j=0;j<4;j++)

            System.out.print(matrix [i] [j] + " ");

         System.out.println();

      }

      int sum = 0;

      for (int row=0; row < matrix.length; row++)

    {

        for (int col=0; col < matrix[row].length; col++)

        {

            sum = sum + matrix[row][0];

        }

I keep getting the wrong answers when the rows are added. 

The sum for row 0 is 4 (should be 10)

Oct 3rd, 2015

Thank you for the opportunity to help you with your question!

the output is correct.

there is fault in line:  sum = sum + matrix[row][0];

Please let me know if you need any clarification for the doubts. I'm always happy to answer your questions. Looking forward to help you again. thank you. :)
Sep 21st, 2015

Hello,

Thank you for pointing that out. I was assuming there was something wrong with that line, I am just not sure how to fix it. 

Sep 21st, 2015

Studypool's Notebank makes it easy to buy and sell old notes, study guides, reviews, etc.
Click to visit
The Notebank
...
Oct 3rd, 2015
...
Oct 3rd, 2015
Dec 2nd, 2016
check_circle
Mark as Final Answer
check_circle
Unmark as Final Answer
check_circle
Final Answer

Secure Information

Content will be erased after question is completed.

check_circle
Final Answer