Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Given an incomplete program below, complete the program by filling in the blanks with an appropriate C++ statement according to the instructions stated in the
Given an incomplete program below, complete the program by filling in the blanks with an appropriate C++ statement according to the instructions stated in the comments. This program copies all the elements of a 1D array to a 2D array. Then, find the sum of squares of all elements. Note: Please write C ++ statements WITHOUT blank spaces unless it is absolutely needed. Example: int num,a,b; #include #include using namespace std; 1/a) Write sumsquare function prototype (2 marks) int main() /*b) Declare 2D array type integer, 2 columns 3 rows named val (1 mark)*/ 12 13 /*c) Declare 1D array type integer named num with size declarator 6 with initial value: 1,2,3,4,5,6 (2 marks)*/ }; 17 int n; 1/d) Copy all elements of array num to val (3 marks) for (int i=; ; i++) //for row for (int j ; ; j++) //for column { n++; } /*e) Call function sumsquare, pass array val and display the returned value (2 marks)*/ 38 return @; 42 43 // sumsquare function definition double sumsquare(int A[][2], int x) { double sum = @, square; 1/f) Calculate total of square of all elements in array (5 marks) for (int i=; ; i++) //for row for (int j = 0; ; j++) { //for column square - return sum
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started