Quiz 5: Ch5 Functions

10 Questions | Total Attempts: 64

SettingsSettingsSettings
Please wait...
Function Quizzes & Trivia

.


Questions and Answers
  • 1. 
    What is the output for the segment of code shown below: 
    • A. 

      B9

    • B. 

      6

    • C. 

      9

    • D. 

      B

  • 2. 
    Which of the following is FALSE about function ?
    • A. 

      The formal parameters listed in a function header, must include each parameter’s data type and name.

    • B. 

      The names of the formal parameters in the function header must be the same to the names of the actual arguments in the function call.

    • C. 

      The sequence of parameters in the function call and parameters in the function header must be the same.

    • D. 

      The function of a void function can be called in the numerical expression.

  • 3. 
    Given the function prototype: void test (int, int, int&); Which of the following calling function statements is INVALID?
    • A. 

      Test(2, 4, 5);

    • B. 

      Test(x, y, z);

    • C. 

      Test (d, 4, f);

    • D. 

      Test (7, 14, c);

  • 4. 
    What is the return type for  the following function prototype ?char  FindCode(int, double,  float, char) ; 
    • A. 

      Char

    • B. 

      Int

    • C. 

      Float

    • D. 

      Double

  • 5. 
    The function prototype Example( ) is as given below:void Example (int x, int y, float z);Which of the following function call is VALID?
    • A. 

      Example (int x, int y, float z);

    • B. 

      Example (x, y, z);

    • C. 

      A = Example (int x, int y, float z);

    • D. 

      A = Example (x, y, z);

  • 6. 
    Which of the following function prototypes with two integer parameters can be used for a void function named CalculateBalance?
    • A. 

      Void CalculateBalance (int);

    • B. 

      Int CalculateBalance (void);

    • C. 

      Void CalculateBalance (int, int);

    • D. 

      Int CalculateBalance (int, int);

  • 7. 
    What is the output for the following program?char testYou (int a, int& b, float c){   a = b * c;   b = a + c;   return 'K';}void main{   int x = 3;   int y = 4;   int z = 2;   char T = testYou (x,y,z);   cout<<x<<" "<<y<<" "<<z<<" "<<T;}
    • A. 

      3 7 2 K

    • B. 

      3 10 2 K

    • C. 

      3 4 2 'K'

    • D. 

      3 7 2 T

  • 8. 
    • A. 

      Char

    • B. 

      Int

    • C. 

      Float

    • D. 

      Double

  • 9. 
    Given the following prototype:float test (int, int, int);Which of the following is VALID?
    • A. 

      Cout

    • B. 

      Cout

    • C. 

      Cout

    • D. 

      Cout

  • 10. 
    What is the output of the following program segment?void func (int &, int);void main( ){     int a = 10, b = 20;     func (a, b);     cout << a << " " <<b;}void func (int &x, int y){     x = x /3;     y = x;     cout << x << " " << y << endl;}
    • A. 

      3 3 3 20

    • B. 

      3 3 10 20

    • C. 

      10 20 3 3

    • D. 

      3 20 3 3