The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 2 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
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) 10
b) 1
c) 17
d) 6
-----------