Can anyone help me with these problems? Thanks. 1. Consider the function definit
ID: 3559592 • Letter: C
Question
Can anyone help me with these problems? Thanks.
1. Consider the function definition
Suppose that the caller has variables myInt and mydouble whose values are 20 and 4.8, respectively. What are the values of myInt and mydouble after return from the following function call?
a. myInt = 20 and mydouble = 43.5 b. myInt = 40 and mydouble = 4.8 c. myInt = 20 and mydouble = 4.8 d. myInt = 40 and mydouble = 43.5 e. None of the above.
4. Consider the function definition
Suppose that the caller has variables myInt and mydouble whose values are 20 and 4.8, respectively. What are the values of myInt and mydouble after return from the following function call?
a. myInt = 20 and mydouble = 43.5 b. myInt = 40 and mydouble = 4.8 c. myInt = 20 and mydouble = 4.8 d. myInt = 40 and mydouble = 43.5 e. None of the above.
10. Consider the function definition
}
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?
a. gamma = 10 and delta = 20 b. gamma = 110 and delta = 20 c. gamma = 10 and delta = 999 d. gamma = 110 and delta = 999 e. None of the above.
1. Given the function definition
what is the value of the expression IsZip(2.4)?
a. 0.0
b. true
c. 2.4
d. false
e. "somedouble == 0.0"
5. Given the function prototype
which of the following statements use valid (i.e. syntactically correct) calls to the IsGreater function? (The data types of the variables are suggested by their names.)
a.
b.
c.
D.b and c above
E.a, b, and c above
6. What happens if a value-returning function with the prototype
is called by using the following statement? (alpha and beta are int variables.)
a. The compiler issues a syntax error message.
b. The function is executed, and the function value is discarded.
c. The function is executed, and the function value is assigned to alpha.
d. The function is not executed, and the program halts with a run-time error
message.
e. None of the above.
Explanation / Answer
1. Consider the function definition
void Demo(int intVal, double& doubleVal)
{
intVal = intVal * 2;
doubleVal = double(intVal) + 3.5;
}
Suppose that the caller has variables myInt and mydouble whose values are 20 and 4.8, respectively.
What are the values of myInt and mydouble after return from the following function call?
Demo(myInt, mydouble);
Demo(20, 4.8) since mydouble passed by reference ...it will change after coming back from functin..
inside function, intVal = 40 => doubleVal = 40+3.5 = 43.5
so myInt will have 20 and mydouble will have 43.5 .
a. myInt = 20 and mydouble = 43.5
4. Consider the function definition
void Demo(int& intVal, double doubleVal)
{
intVal = intVal * 2;
doubleVal = double(intVal) + 3.5;
}
Suppose that the caller has variables myInt and mydouble whose values are 20 and 4.8, respectively.
What are the values of myInt and mydouble after return from the following function call?
Demo(myInt, mydouble);
Demo(20, 4.8) since myInt passed by reference ...it will change after coming back from functin..
inside function, intVal = 40.
so myInt will have 40 and mydouble will have 4.8.
b. myInt = 40 and mydouble = 4.8
10. 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 passed by referene so it will change value inside function thus..
gamma = gamma + 100; gamma = 10+100 = 110
gamma and delta will have 110 and 20.
b. gamma = 110 and delta = 20
1. Given the function definition
bool IsZip(double somedouble)
{
return (somedouble == 0.0);
}
what is the value of the expression IsZip(2.4)?
d. false
5. Given the function prototype
bool IsGreater(int, int);
which of the following statements use valid (i.e. syntactically correct) calls to the IsGreater function?
(The data types of the variables are suggested by their names.)
a.someBoolean = IsGreater(someInt, 8);
b.if (IsGreater(5, someInt))
intCounter++;
c.while (IsGreater(inputInt, 23))
cin >> inputInt;
E.a, b, and c above all are VALID.
6. What happens if a value-returning function with the prototype
double Average(int, int, int);
is called by using the following statement? (alpha and beta are int variables.)
Average(alpha, 34, beta);
b. The function is executed, and the function value is discarded.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.