Consider the following skeletal C program: void fun1(void); /* prototype */ void fun2(void); /* prototype */ void fun3(void); /* prototype */ void main() {  int a, b, c;  . . . } void fun1(void) {  int b, c, d;  . . . } void fun2(void) {  int c, d, e;  . . . } void fun3(void) {  int d, e, f;  . . . } Given the following calling sequences and assuming that dynamic scoping is used, what variables are visible during the execution of the last function? Include with each visible variable the name of the function in which it was defined. a. main calls fun1; fun1 calls fun2; fun2 calls fun3. b. main calls fun1; fun1 calls fun3. c. main calls fun2; fun2 calls fun3; fun3 calls fun1. d. main calls fun3; fun3 calls fun1. e. main calls fun1; fun1 calls fun3; fun3 calls fun2.     Consider the following program, written in JavaScript-like syntax: // main program var x, y, z; function sub1() { var a, y, z; . . . } function sub2() {  var a, b, z;  . . . } function sub3() {  var a, x, w;  . . . } Given the following calling sequences and assuming that dynamic scoping is used, what variables are visible during the execution of the last subprogram activated? Please include the unit's name where it is declared with each visible variable. a. main calls sub1; sub1 calls sub2; sub2 calls sub3. b. main calls sub1; sub1 calls sub3. c. main calls sub2; sub2 calls sub3; sub3 calls sub1. d. main calls sub3; sub3 calls sub1. e. main calls sub3; sub3 calls sub2; sub2 calls sub1.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Consider the following skeletal C program:


void fun1(void); /* prototype */
void fun2(void); /* prototype */
void fun3(void); /* prototype */
void main() {
 int a, b, c;
 . . .
}
void fun1(void) {
 int b, c, d;
 . . .
}
void fun2(void) {
 int c, d, e;
 . . .
}
void fun3(void) {
 int d, e, f;
 . . .
}
Given the following calling sequences and assuming that dynamic scoping is used, what
variables are visible during the execution of the last function? Include with each visible variable
the name of the function in which it was defined.
a. main calls fun1; fun1 calls fun2; fun2 calls fun3.
b. main calls fun1; fun1 calls fun3.
c. main calls fun2; fun2 calls fun3; fun3 calls fun1.
d. main calls fun3; fun3 calls fun1.
e. main calls fun1; fun1 calls fun3; fun3 calls fun2.

 

 

Consider the following program, written in JavaScript-like syntax:


// main program
var x, y, z;
function sub1() {
var a, y, z;
. . .
}
function sub2() {
 var a, b, z;
 . . .
}
function sub3() {
 var a, x, w;
 . . .
}
Given the following calling sequences and assuming that dynamic scoping is used, what
variables are visible during the execution of the last subprogram activated? Please include the
unit's name where it is declared with each visible variable.
a. main calls sub1; sub1 calls sub2; sub2 calls sub3.
b. main calls sub1; sub1 calls sub3.
c. main calls sub2; sub2 calls sub3; sub3 calls sub1.
d. main calls sub3; sub3 calls sub1.
e. main calls sub3; sub3 calls sub2; sub2 calls sub1.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

For the first problem, in parts b and c, how are the variables being taken from functions that they are not defined in? To clarify, in part c, how is the variable "b" taken from fun2 when it is not defined in that in function. Shouldn't the answer there just be "b(fun1)" 

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Fundamentals of Computer System
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY