1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Papessa [141]
3 years ago
15

Assume the following JavaScript program was interpreted using static-scoping rules. What value of x is displayed in function sub

1? Under dynamic-scoping rules, what value of x is displayed in function sub1? var x; function sub1() { document.write("x = " + x + ""); } function sub2() { var x; x = 10; sub1(); } x = 5; sub2();
Computers and Technology
1 answer:
kirill [66]3 years ago
6 0

Answer:

The value of x in both scope can be described as follows:

i) Static scope:

x=  5

ii) Dynamic scope:

x=10

Explanation:

The static scoping  is also known as an arrangement, which is used in several language, that defines the variable scope like the variable could be labelled inside the source that it is specified.

i) program:

function sub1()  //defining function sub1

{

  print("x = " + x + ""); //print value

}

function sub2()//defining function sub2

{

   var x; //defining variable x

   x = 10; //assign value in variable x

   sub1();  //caling the function sub1

}

x = 5; //assign the value in variable x

sub2(); //call the function sub2

In Dynamic scoping, this model is don't see, it is a syntactic mode that provides the framework, which is used in several program. It doesn't care how well the code has been written but where it runs.  

ii) Program:

var x //defining variable x

function sub1()  //defining a function sub1

{

print("x = " + x + ""); //print the value of x

}

x = 10; // assign a value in variable x

sub2(); // call the function sub2

function sub2() //defining function sub2

{

var x; //defining variable x

x = 5; // assign value in x

sub1();//call the function sub1

}

You might be interested in
The basic input/output system (bios locates the boot loader program on a linux system by reading the __________ on the hard driv
Diano4ka-milaya [45]
If the disk was formatted with fdisk, the MBR (Master Boot Record).
6 0
3 years ago
Hanging out with friends, watching your favorite TV show, and buying a pair of new shoes are all examples of _____ for doing wel
SpyIntel [72]
<span>Hanging out with friends, watching your favorite TV show, and buying a pair of new shoes are all examples of rewards for doing well in school. As the result of doing well in studies, a person can hang out with friends, watch their own favorite TV show and can buy a new pair of shoes. Hence all these things are the rewards that are being generated for a good performance in school.</span>
8 0
3 years ago
Read 2 more answers
Write a program code which asks for 80 numbers between 100 and 1000 to be entered.
Firlakuza [10]

Answer:

If you are using Python,

```count = 0

for i in range(0, 79):

a = int(input("Input a number: "))

if 100 <= a <= 1000:

 if a > 500:

  count += 1

else:

 print("Please input a number between 100 and 1000!")

 i -= 1

print(count)```

Explanation:

count refers to the number of 500s and above,

the for loop is required for the program to loop 80 times,

a is the input collected,

the nested if is to check whether the number is above 500 and the if is used to check if the number is between 100 and 1000 if not, it will output that you need to input a number between 100 and 1000,

the i-=1 is required to make sure that part wasn't counted.

and the last print is to output the number of numbers above 500

8 0
3 years ago
पुजवय<br>शब्दस्य<br>विरूदायक​
statuscvo [17]

Answer:

के?

Explanation:

5 0
3 years ago
You are planning to write a guessing game program where the user will guess an integer between one and 20. Put the commented ste
Rudiy27

Answer:

1. Generate a random number

2. Ask the user for a guess.

3. Compare the user's answer to the correct number.

4. Give the user a hint as to whether their guess is too high or too

Explanation:

Leave a like and brainist if this helped

7 0
3 years ago
Other questions:
  • Cryptolocker is an example of what type of malware?
    11·1 answer
  • Define a function CoordTransform() that transforms the function's first two input parameters xVal and yVal into two output param
    12·1 answer
  • If the base-10 system stops with the<br> number 9, then why isn't it called<br> base-9?
    15·1 answer
  • What is the best kernel synchronization solution on multicore systems when a lock is held for brief periods ?
    14·1 answer
  • ___signs tell you what you can or can't do, and what you must do ?
    5·2 answers
  • Why is Linux widespread in academic environments?
    7·1 answer
  • Encryption is an important topic in math and computer science. It keeps your personal information safe online.
    6·1 answer
  • I have a problem with my Nintendo DS lite does anyone know how to fix it?
    8·1 answer
  • WAP to find area of circle​
    12·1 answer
  • You will include code that will validate all user input. If the user inputs an invalid value, the program will respond with an e
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!