Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Dev C++ Question 2 (22 Marks) a) Given an incomplete program below, complete the program by filling in the blanks with an appropriate C++ statement

Dev C++ image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Question 2 (22 Marks) a) 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 2D array to a ID array. Then, double the sum of all the elements. (12 marks) #include using namespace std; //i) Write DoubleTotal function prototype (1.5 marks) 000 UN int main() /*ii) Declare 2D array type integer, 3 rows 2 columns named Arri with initial value: 1,2,3,4,5,6 (1.5. marks) */ /*iii) Declare 1D array type integer named Arr2 with size declarator 6 (0.5 mark) */ 14 15 16 17 18 19 20 int n = 0; //iv) Copy all elements of array Arri to Arr2 (3 marks) NH NNNNNNNNN n++; ) /*v) Call function DoubleTotal, pass array Arr2 and display the returned value (1.5 marks) / 28 29 30 31 32 33 34 return 0; //DoubleTotal Function definition double DoubleTotal(int A[], int x){ double sum= 0; 35 36 37 38 39 40 V/vi) Calculate sum of all elements (2.5 marks) V/vii) Multiply sum by 2 (1.5 marks) 42 43 44 45 46 return sum b) Trace the following program segment. Write the elements of each array after execution of the statement(s) in Table 2. (10 marks) 1 2 3 4 int subs [3] -(1,2,3), mask2D[3] [3] ={17), 2, 4, 12,9,5); int i, j, x = 1; for(i 0; i

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

Students also viewed these Databases questions

Question

=+2 Why are international employment standards important to IHRM?

Answered: 1 week ago

Question

=+1 Why are local employment laws important to IHRM?

Answered: 1 week ago

Question

=+ Are some laws more important than others? If so, which ones?

Answered: 1 week ago