Name_______________________ Login___________________SID________

 

CS 010: Introduction to Computer Science I

Quiz 5: 10 minutes

 

  1. Parameters and return types can only be fundamental types.
    1. TRUE
    2. FALSE

 

  1. A return statement always terminates the program.
    1. TRUE
    2. FALSE

 

  1. Assuming that x is a double, the following statement is a valid statement.

cout << sqrt(pow(x, 4));

 

    1. TRUE
    2. FALSE

 

 

For the next 3 questions, assume there is a the following function header (prototype):  

void func(int, double)

 

  1. Given the function func above, the following statement is valid.

cout << func(4, 13.9);

 

    1. TRUE
    2. FALSE

 

  1. Given the function func above, the following statement is valid.

func(rand(), 2.2);

 

    1. TRUE
    2. FALSE

 

  1. Given the function func above, the following statement is valid.

func(7.7, 11);

 

    1. TRUE
    2. FALSE

 

  1. The expression    rand() % 50 + 10    would result in a range of
    1. 0-49
    2. 1-50
    3. 10-50
    4. 10-59
    5. None of the above

 

Use the code below for the next 3 questions.

double func1(double x)

{

            if (x <= 20)

            {

                        return x;

            }

            else

            {

                        return 100;

            }

}

 

double func2(double a)

{

            double b = pow(a, a);

            cout << b << endl;                               // OUTPUT 1

           

            double c = func1(b);

            cout << c << endl;                                // OUTPUT 2

 

            return b + c;

}

 

int main()

{

            cout << func2(3) + 5 << endl;              // OUTPUT 3

            return 0;

}

 

  1. What will OUTPUT 1 print?
    1. 3
    2. 9
    3. 27
    4. 32
    5. None of the above

 

  1. What will OUTPUT 2 print?
    1. 3
    2. 20
    3. 27
    4. 100
    5. None of the above

 

  1. What will OUTPUT 3 print?
    1. 8
    2. 41
    3. 127
    4. 132
    5. None of the above