Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone please please help? C++ code Problem: You are to create a program that will read a file to input values into a 2-D

Can someone please please help? C++ code

Problem: You are to create a program that will read a file to input values into a 2-D array, calculate the sum of each row and store the sums in a 1-D array, then output the sum of each row. The array should contain 12 rows and 6 columns of whole numbers. You should have 4 function total: the main function, the function to read from a file, a function that accepts a 2-D array and stores the sum of each row in a 1-D array, one function to output the elements of the 1- D array.

The function to read values from a file should accept a 2-D array, the number of rows and the number of columns for that array. Then store the values from the file in the 2-D array. Thevalues are stored in a file named Lab-9.txt.

The function to sum the elements of each row should accept the filled 2-D array, the number of rows, the number of columns, and an empty 1-D array (to store the sum). Calculate the sum of each row and store in the 1-D array.

The function to output the elements of a 1-D array should accept the 1-D array and the number of values stored in the array. Then output the elements of the array one at a time (the cout to output an array element should only contain one array element) to the screen. (You may reuse the function to output elements of the array that you wrote for Lab 8 if you modify it to output to the screen rather than a file).

The main function should declare the 2-D array and the 1-D array to hold the sums. Next the main function should call the function to fill the array. Next the main function should call the function to determine the sum of each row. Next the main function should call the function to output the values of the 1-D array which contains the sums of each row.

Remember that your function definitions should appear after main and your program should contain the usual introductory comments at the beginning of the file plus comments specific to each function immediately before that function. The function comments should contain the purpose of the function, input needed (passed to the function and/or interactive input within the function), output from the function (returned back to the function call and/or output to screen), and processing (how to get the output from the input).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Students also viewed these Databases questions