Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

QUESTION 11 Consider the function definition void Demo( int intVal, float& float

ID: 3774669 • Letter: Q

Question

QUESTION 11

Consider the function definition

void Demo( int intVal,
                    float& floatVal )
{
      intVal = intVal * 2;
      floatVal = float ( intVal) + 3.5;
}

Suppose that the caller has variables myInt and myFloat whose values are 20 and 4.8, respectively. What are the values of myInt and myFloat after return from the following function call?

Demo( myInt, myFloat );

myInt = 20 and myFloat = 43.5

myInt = 40 and myFloat = 4.8

myInt= 20 and myFloat = 4.8

myInt= 40 and myFloat = 43.5

none of the above

5 points   

QUESTION 12

Consider the function definition

void Demo( int& intVal,
                    float floatVal )
{
      intVal = intVal * 2;
      floatVal = float ( intVal ) + 3.5;
}

Suppose that the caller has variables myInt and myFloat whose values are 20 and 4.8, respectively. What are the values of myInt and myFloat after return from the following function call?

Demo( myInt, myFloat );

myInt = 20 and myFloat = 43.5

myInt = 40 and myFloat = 4.8

myInt= 20 and myFloat = 4.8

myInt= 40 and myFloat = 43.5

none of the above

5 points   

QUESTION 13

Consider the function definition

void DoThis( int& alpha,
                    int beta )
{
      int temp;     

      alpha = alpha + 100;
      temp = beta;
      beta = 999;
}

Suppose that the caller has integer variables gamma and delta whose values are 10 and 20, respectively. What are the values of gamma and delta after return from the following function call?

DoThis( gamma, delta );

gamma = 10 and delta = 20

gamma = 110 and delta = 20

gamma = 10 and delta = 999

gamma = 110 and delta = 999

none of the above

5 points   

QUESTION 14

If an ampersand (&) is not attached to the data type of a formal parameter, then the corresponding actual parameter can be:

a constant

a variable name

an arbitrary expression

a and b above

a, b, and c above

3 points   

QUESTION 15

For the function definition

void Func ( int& gamma )
{
      gamma = 3 * gamma;
}

which of the following comments describes the direction of data flow for gamma?

in

out

inout

none of the above

a.

myInt = 20 and myFloat = 43.5

b.

myInt = 40 and myFloat = 4.8

c.

myInt= 20 and myFloat = 4.8

d.

myInt= 40 and myFloat = 43.5

e.

none of the above

Explanation / Answer

QUESTION 13:

void Demo( int intVal,
                    float& floatVal )
{
      intVal = intVal * 2;
      floatVal = float ( intVal) + 3.5;
}

Answer:B

gamma = 110 and delta = 20

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote