Answered step by step
Verified Expert Solution
Question
1 Approved Answer
4. Consider the following program, written in C. int i = 10; void p(void) { printf(G1: %d , i); i++; printf(G2: %d , i); }
4. Consider the following program, written in C.
int i = 10;
void p(void) { printf("G1: %d ", i); i++; printf("G2: %d ", i); }
void h(int i) { printf("F1: %d ", i); i++; p(); printf("F2: %d ", i); }
int main( ) { int i = 100; printf("N1: %d ", i); h(i); printf("N2: %d ", i); p(); printf("M3: %d ", i); }
a) Complete the following trace, by showing what gets printed when Cs usual static scoping is used.
N1: F1: G1: G2: F2: N2: G1: G2: N3:
4
b) Assume NewC is a new programming language that is identical to C, except that it uses dynamic scoping. Complete the following trace, by showing what gets printed when NewC is used.
N1: F1: G1: G2: F2: N2: G1: G2: N3:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started