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. :)