in Compiler Design edited by
12,886 views
43 votes
43 votes

The following program fragment is written in a programming language that allows global variables and does not allow nested declarations of functions.

global int i=100, j=5;
void P(x) {
	int i=10;
    print(x+10);
    i=200;
    j=20;
    print (x);
}
main() {P(i+j);}

If the programming language uses dynamic scoping and call by name parameter passing mechanism, the values printed by the above program are

  1. $115, 220$
  2. $25, 220$
  3. $25, 15$
  4. $115, 105$
in Compiler Design edited by
12.9k views

4 Comments

0
0
The programming language and its rules for global variables, nested function declarations, dynamic scoping, and call by name parameter passing must be known. Additionally, the program must be executed in order to determine the values printed, dynamic scoping and call by name parameter passing can lead to unpredictable behavior and are not commonly used in modern programming languages. It is generally recommended to use lexical scoping and call by value or call by reference parameter passing instead. Global variables can be accessed and modified by any function in the program, and the specific behavior of a function may depend on the values of global variables at the time the function is called. In a language that uses dynamic scoping and call by name parameter passing, the values of the local and global variables at the time of a function call may affect the behavior of the function. Additionally, the specific behavior of the parameter passing mechanism may affect how the values of the parameters are used in the function.
0
0

@samir757 here we will use rename concept so your answer is not correct but i am not able to understand best answer anyone please help me?

0
0

5 Answers

2 votes
2 votes

ans is A

Answer:

Related questions