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: 664698 • 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:

Given the above code which of the following parameters are passed as value parameters in the statement labeled //----3 above

a) dataArray
b) resultArray
c) SIZE
d) All of the above
e) None of the above

Explanation / Answer

Ans:

E)None of the above

Explanation:

value parameters is a formal parameter.Value parameters are parameters as they appear in function declarations.

A parameter declared with no modifiers is a value parameter. A value parameter corresponds to a local variable that gets its initial value from the corresponding argument supplied in the method invocation.

void foo(int[], int, int&);(this is value parameter)
void boo(int[], int[], int);(this is value parameter)