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: 664699 • 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 is the output of the cout statement in the main program (statement labeled 2)?

a) 1
b) 10
c) 17
d) 6

Explanation / Answer

b) 10