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

Which of the following is a statement that causes a function to execute? for loo

ID: 3779387 • Letter: W

Question

Which of the following is a statement that causes a function to execute? for loop do-while loop function prototype function call None of these With the function can modify the argument in the calling part of the program. passing by value passing by reference passing by name passing by data type None of these Given the following function definition void calc (int a, int & b) {int c; c = a + 2; a = a + 3; b = c + a;} What is the output of the following code fragment that invokes calc? (All variables are of type int) x = 1; y = 2; z = 3; calc(x, y); cout

Explanation / Answer

14) d) function call : to execute a function we call the function with its name. for example to execute calc function we can write calc(); to execute all the statements in it.

15) b) pass by reference : when we pass a reference of a variable, we are actually passing the address where the value is stored thats why if we modify that variable, all the alias that points to that address will reflect the changes.

16) a) 1 2 3 : because we did not pass the reference in calc function , i.e. calc(&x, &y) instead we pass only their value calc(x,y) so any changes that calc() function does doesn't reflect in original x,y values. z is completely isolated so its not going to change anyway.

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