Consider the following JavaScript program: var x, y, z; function sub1() {var a,
ID: 3578930 • Letter: C
Question
Consider the following JavaScript program: var x, y, z; function sub1() {var a, y, z; function sub2() {var a, b, z; > > function sub3() {var a, x, w; >" List all the variables, along with the program units where they are declared, that are visible in the bodies of sub1, sub2, and sub3, assuming static scoping is used. Consider the following C program: void fun(void) {int a, b, c; t* definition 1 *l while (...){int b, c, d;/'definition 2 7 int c. d, e; i* definition 3 7 For each of the four marked points in this function, list each visible variable, along with the number of the definition statement that defines it.Explanation / Answer
var x,y,z; Here x, y, z are global variables which are declared outside the functions. These can be used any where in the program
function sub1() Definition of functin sub1
{
var a, y, z; Variables a, y, z are declared within the function sub1. These are local variables which can be used only in function sub1
.......
function sub2() Definition of functin sub2
{
var a, b, z; Variables a, b, z are declared within the function sub2. These are local variables which can be used only in function sub2
.......
}
.....
}
function sub3() Definition of functin sub3
{
var a, x, w; Variables a, x, w are declared within the function sub3. These are local variables which can be used only in function sub3
.......
}
In the second code ie code of c program
the function is void fun(void)
in definition 1 we have 3 local variables a, b, c which can be used within the definition
in definition 2 we have 3 local variables b, c, d which can be used within the definition
in definition 3 we have 3 local variables c, d, e which can be used within the definition
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.