What is the output of the following program if the parameter passing mechanism is: a) reference mechanism, variable (call by reference) b) copy mechanism, copy-in (call by value) c) copy mechanism, copy-in-copy-out (value-return technique) int x=5,y=5; int notcalled (int a) { if (a

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 15SA
icon
Related questions
Question
Please send me answer within 10 min!! Please solve all the questions and give explanation!! I will rate you good for sure!!
What is the output of the following program if the parameter passing mechanism is:
a) reference mechanism, variable (call by reference)
b) copy mechanism, copy-in (call by value)
c) copy mechanism, copy-in-copy-out (value-return technique)
int x=5, y=5;
int notcalled (int a) {
if (a<x)
return x+a+a;
}
else
}
void f(int a, int b) {
a)
return x
}
int main() {
x++; y;
a+=x;
b-=y;
printf("x: %d, y:%d, a:%d, b: %d\n");
int p-3,q=9;
f(p,q);
printf("x:%d, y:%d, p:%d, q: %d\n");
f(y,x);
printf("x: %d, y: %d");
return 0;
b)
d) Assume x-5 in main () and you call not called (++x). What is the value of x after the call. Assuming:
Eager evaluation, copy-in (pass by value):
c)
Normal order evaluation (pass by name):
Transcribed Image Text:What is the output of the following program if the parameter passing mechanism is: a) reference mechanism, variable (call by reference) b) copy mechanism, copy-in (call by value) c) copy mechanism, copy-in-copy-out (value-return technique) int x=5, y=5; int notcalled (int a) { if (a<x) return x+a+a; } else } void f(int a, int b) { a) return x } int main() { x++; y; a+=x; b-=y; printf("x: %d, y:%d, a:%d, b: %d\n"); int p-3,q=9; f(p,q); printf("x:%d, y:%d, p:%d, q: %d\n"); f(y,x); printf("x: %d, y: %d"); return 0; b) d) Assume x-5 in main () and you call not called (++x). What is the value of x after the call. Assuming: Eager evaluation, copy-in (pass by value): c) Normal order evaluation (pass by name):
Expert Solution
steps

Step by step

Solved in 5 steps with 7 images

Blurred answer
Knowledge Booster
ADT and Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr