c++ #3 c) Multiple Choice: Circle the correct answer Assume that the following f
ID: 3910294 • Letter: C
Question
c++ #3
c) Multiple Choice: Circle the correct answer Assume that the following function header is for a display V alue function void display Value (int value Assume that the following code segments appear in main function. Which contains a legal call to the display Value function? a. int x = 7; void display Value(x): display Value(x); int x = 7; c. display Value(int x); d. int x-7; displayValue(x) Point 3 3. Mark the following statements as TRUE or FALSE: a) A funct ion's changes to a variable that is passed-by-value do not affect the original variable b) Constants, variables, and the values of expressions ma y be passed as arguments to a When an argument value is passed to a method, the receiving parameter variable is declared within the body of the method. c)Explanation / Answer
1) Answer for the first question in: C
???void displayValue(int value) function's legal call must be as follows:
int x = 7;
displayValue(x);
to call a function we follows <function name>(<value(s) or variable(s) or reference(s)>);
3.a) A funcitons's changes to a variable that is passed-by-value do not affect the original variable. True
Yes, if function is called by passed-by-value,that value will never affect the original variable until unless it is a reference variable. passed-by-value argument is input for that function. after passing the value to the function, it will copy the value to function's local block which will discard after function execution. in case of passed-by-reference, the reference will copy to local block where changes will reflect on orginal variable
3.b Constants, variables, and the values of expressions may be passed as arguments to a method True
we can pass Constants, variables and values of expressions to a method. argument is nothing but a statement, if a statement is an expression then the final value of argument is output of the expression.
3.c When an argument value is passed to a method, the receiving parameter variable is declared within the body of the method. False
the receiving parameter variable will always be declared at function declaration only. in the first question of this paper we have void displayValue(int value); here the function declaration stating that displayValue funciton requries value which must be int type
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.