004-009-009

Traversing Rows and Columns in 2D Array

Hard

Problem Description

Traversing Rows and Columns in 2D array

In this problem, you will create a program that traverses a 2D array using nested loops, calculates the sum of each row and the total sum of all elements, and displays the results to standard output.

Learning Objective: Traverse all elements of a 2D array using nested loops

Overview

Calculate the sum of each row and the total sum of a 2D array.

Specifications

  • Create a 2D array {{1,2,3}, {4,5,6}}
  • Output the sum of each row
  • Output the total sum of all elements

Output Format

Row 0 sum: 6
Row 1 sum: 15
Total: 21

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?

Sign Up