Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Use the following code to answer the question. #include <iostream> using namespa

ID: 664700 • Letter: U

Question

Use the following code to answer the question.

#include <iostream>
using namespace std;
void foo(int[], int, int&);
void boo(int[], int[], int);
int main()
{
   const int SIZE = 5;
   int dataArray[SIZE] = { 1,2,6,3,10 };
   int x = 0;
   int resultArray[SIZE] = {};
   foo(dataArray, SIZE, x); //--------1
   cout << x; //--------2
   boo(dataArray, resultArray, SIZE); //---------3

   system("pause");
   return 0;
}

void foo(int a[], int length, int& y)
{
   y = a[0];
   for (int i = 1; i < length; i++)
   {
       if (y < a[i])
           y = a[i];
   }
}

void boo(int a[], int b[], int length)
{
   for (int i = 0; i < length; i++)
       b[i] = a[i] * a[i];

}

Question:

What are the values stored in resultArray after boo method call in statement labeled //------3 above
(do not care the order in the resultArray. If resultArray[]={1,3,4,2,5}, the values stored in resultArray arer 1 2 3 4 5).

a) 0 0 0 0 0
b) 1 4 9 36 100
c) 1 2 3 6 10
d) Nothing

Explanation / Answer

After analysing and executing this program i found the following is stored in the resultArray

The answer is option B - > 1 4 9 36 100

the answer is based on the given program.

Hope you are convinced.