previous | start | next

Input and Call by Reference

In the previous example there was no prompt to the user to enter the input.

Suppose we decide we want to modify the code like by adding a function getInput to read in the three value like this:

int main()
{
  int a, b, c;
  int max;
  double avg;

  getInput(a,b,c);
  sort(a,b,c);
  max = findmax(a,b,c);
  avg = average(a,b,c);

  cout << a << " " 
       << b << " "
       << c << endl;

  cout << "Max = " << max << endl;
  cout << "Average = " << avg << endl;
  return 0;
}

What should the declaration for getInput be? (Should it use call by value or call by reference?)



previous | start | next