Content Frame
Note for screen reader users: There is text between the form elements on this page. To be sure that you do not miss any text, use item by item navigation methods, rather than tabbing from form element to form element.
Skip Breadcrumb Navigation
Home  arrow Student Resources  arrow Quizzes  arrow Chapter 3

Chapter 3

Function Basics

This activity contains 10 questions.

Question 1.
To access functions such as abs, rand, or exit, what should be added to the top of the program?

 
End of Question 1


Question 2.
How could we simulate rolling two six sided dice, adding their values together to produce a result from 2-12?

 
End of Question 2


Question 3.
What does the return type of void refer to?

 
End of Question 3


Question 4.
Which of the following functions correctly returns the minimum of three integers passed in?

 
End of Question 4


Question 5.
What will the following output?
void foo(int x, int y);

int main()
{
  int x=1, y=2;
  foo(y, x);
  return 0;
}

void foo(int x, int y)
{
   cout << "X = " << x << "  Y = " << y << endl;
   return;
}

 
End of Question 5


Question 6.
Which of the following function prototypes is equivalent to the following prototype? int min(int num1, int num2, int num3);

 
End of Question 6


Question 7.
What will the following output?
void foo();

int main()
{
  int x=1;
  cout << "Before foo, X=" << x;
  foo();
  cout << "  After foo, X=" << x;
  return 0;
}

void foo()
{
   int x = 2;
   cout << "In foo, X = " << x;
   return;
}

 
End of Question 7


Question 8.
What will the following output?
void foo();
int x;

int main()
{
  x=1;
  cout << "Before foo, X=" << x;
  foo();
  cout << "  After foo, X=" << x;
  return 0;
}

void foo()
{
   x = 2;
   cout << "In foo, X = " << x;
   return;
}

 
End of Question 8


Question 9.
What will the following code snippet output?
int x=3;
cout << x << endl;
 {
   int x=2;
   cout << x << endl;
   {
     x=1;
   }
   cout << x << endl;
 }
 cout << x << endl;
}

 
End of Question 9


Question 10.
What will a modern C++ compiler output for the following code?
int i=1;
for (int i=0; i<4; i++) {
   cout << i << " ";
}
cout << i << endl;

 
End of Question 10





Pearson Copyright © 1995 - 2010 Pearson Education . All rights reserved. Pearson Addison Wesley is an imprint of Pearson .
Legal Notice | Privacy Policy | Permissions

Return to the Top of this Page