Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. (8 points) Consider the C program given below. You will be asked to determine which variables are visible in a number of different sit-

1. (8 points) Consider the C program given below. You will be asked to determine which variables are visible in a number of different sit- uations. In each case, identify each variable by its name and the line number of its declaration. 1 int h, i; 2 void B(int w) { 3 int j, k; 4 i = 2*w; 5 w = w+1; 6 ... 7 } 8 void A (int x, int y) { 9 float i, j; 10 B(h); 11 i = 3; 12 ... 13 } 14 void main() { 15 int a, b; 16 h = 5; a = 3; b = 2; 17 A(a, b); 18 B(h); 19 ... 20 } (a) C uses static scoping. Say which identifers (including variables and function names) are visible in the bodies of each of the func- tions: main, A, B. 1 (b) If C used dynamic scoping and the calling sequence is main calls B. Say which identifers would be visible in B. (c) If C used dynamic scoping and the calling sequence is main calls A. Say which identifers would be visible in A. (d) If C used dynamic scoping and the calling sequence is main calls A; A calls B. Say which identifers would be visible in B.

2.During the execution of a Java program, can a variable be visible but not allocated? Can a variable be allocated but not visible? Explain your answers.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Administrator Limited Edition

Authors: Martif Way

1st Edition

B0CGG89N8Z

Students also viewed these Databases questions

Question

L A -r- P[N]

Answered: 1 week ago