QUESTION 11 Consider the function definition void Demo( int intVal, float& float
ID: 3774780 • 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 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
Q)11)ans)a
reason:
As we specified the & before the variable name myfloat .Then the result value will be returned after performing operations on it.but not in the case of intVal .as It is not having & symbol before it.
Q)12)ans)b
Reason:As we specified the & before the variable name intVal .Then the result value will be returned after performing operations on it.but not in the case of floatVal .as It is not having & symbol before it.
Q)13)ans)a
Q)14)ans)c
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.