int n = 1; // global print1 (int x) { cout << x + n; plus_n () { n = n + 2; print1 (n); main() { int n; n 20; print1(5); n = 40; plus_n(); cout << n; } what is the output of main under: a. Static scoping rules 6 6 40 b. Dynamic scoping rules 25 84 40

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter2: Using Data
Section: Chapter Questions
Problem 14RQ
icon
Related questions
Question
Solve the two questions fast please
int n
1; // global
%3D
print1 (int x) {
cout << x + n;
plus_n () {
n = n + 2;
print1 (n);
main () {
int n;
n = 20;
print1 (5);
n = 40;
plus_n ();
cout << n;
what is the output of main under:
a. Static scoping rules
6 6 40
b. Dynamic scoping rules
25 84 40
Transcribed Image Text:int n 1; // global %3D print1 (int x) { cout << x + n; plus_n () { n = n + 2; print1 (n); main () { int n; n = 20; print1 (5); n = 40; plus_n (); cout << n; what is the output of main under: a. Static scoping rules 6 6 40 b. Dynamic scoping rules 25 84 40
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Function Arguments
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
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr