Question

In: Computer Science

1. Consider the program below. a. What would the output be in a language with static...

1. Consider the program below.

a. What would the output be in a language with static scoping rules? Explain your answer.

b. What would the output be in a language with dynamic scoping rules? Explain your answer.

int x; //global

int main() {

   x = 11;

   fun1();

   fun2();

}

void fun1() {

   int x = 19;

   fun3();

}

void fun2() {

   int x = 4;

   fun3();

}

void fun3() {

   print(x);

}

Solutions

Expert Solution


Related Solutions

Write Lexical Analyzer program in C language. Below is the sample input and ouput. /* output...
Write Lexical Analyzer program in C language. Below is the sample input and ouput. /* output Enter the string: if(a<b){a=10;} Tokens are identifier :if punctuation mark : ( identifier :a operator:< identifier :b punctuation mark : ) punctuation mark : { identifier :a operator:= constant :10 punctuation mark : ; punctuation mark : } */
Write a machine language program to output your name on the output device. The name you...
Write a machine language program to output your name on the output device. The name you output must be longer than two characters. Write it in a format suitable for the loader and execute it on the Pep/9 simulator. my name is Kevin
trace through the program and what the output would be. If there is an error explain...
trace through the program and what the output would be. If there is an error explain what to change. #include <iostream> using namespace std; int fun(int c, int b); int main(){ int a = 0, b= 5, c = 10; cout<<"a is: "<<a<<" b is: "<<b<<" c is: "<<c<<endl; b=fun(a, c); cout<<"a is: "<<a<<" b is: "<<b<<" c is: "<<c<<endl; while(b==21){ int a = 3; b = a; cout<<"a is: "<<a<<" b is: "<<b<<" c is: "<<c<<endl; } cout<<"a is:...
Write a program to perform the following actions: the language is Java – Open an output...
Write a program to perform the following actions: the language is Java – Open an output file named “Assign14Numbers.txt” – Using a do-while loop, prompt the user for and input a count of the number of random integers to produce, make sure the value is between 35 and 150, inclusive. – After obtaining a good count, use a for-loop to generate the random integers in the range 0 ... 99, inclusive, and output each to the file as it is...
In C Programming Language Write a program to output to a text log file a new...
In C Programming Language Write a program to output to a text log file a new line starting with day time date followed by the message "SUCCESSFUL". Please screenshot the results.
IN ASSEMLY LANGUAGE MASM! please show output run. Write a program that ask the user to...
IN ASSEMLY LANGUAGE MASM! please show output run. Write a program that ask the user to write a string and reverse a string using indirect addressing (may not use the stack - push/pop). The string will be given by the user and be up to 64 characters long. INCLUDE Irvine32.inc INCLUDE macros.inc MAX = 64 .data source BYTE MAX DUP('#'),0 destination BYTE LENGTHOF source DUP('*'),0 actual_length DWORD ? ask BYTE "Enter a String: ",0 .code main proc ; ask user...
Write a C++ program that will output the multiplication table as show below: 1*1=1          2*1=2                 &nbsp
Write a C++ program that will output the multiplication table as show below: 1*1=1          2*1=2                   3*1=3         ……  9*1=1 1+2=2         2*2=4                   3*2=6          ……  9*2=18 …….           …….                   …….           ……  ……. 1*9=9         2*8=18                 3*9=27         ……  9*9=81
7.3 Loops: Output range with increment of 10 IN CORAL LANGUAGE zyBooks Write a program whose...
7.3 Loops: Output range with increment of 10 IN CORAL LANGUAGE zyBooks Write a program whose input is two integers, and whose output is the first integer and subsequent increments of 10 as long as the value is less than or equal to the second integer. Ex: If the input is -15 30, the output is: -15 -5 5 15 25 Ex: If the second integer is less than the first as in 20 5, the output is: Second integer...
Write an assembly language program that prints your first name in the output. Use immediate addressing...
Write an assembly language program that prints your first name in the output. Use immediate addressing with a hexadecimal constant to designate the operand of CHARO for each letter of your name. Comment each line except STOP and END. Cut and paste the Assembler Listing into your document and paste a screen shot of the Output area of the Pep8. Use the name "Kevin" as example Assembler Listing Screen Shot of Output area of the Pep8 program
Identify the directives and statements in the following program. What is the output of the program?...
Identify the directives and statements in the following program. What is the output of the program? [2 points] #include <stdio.h> int main (void) { printf(“Parkinson’s Law: \n Work expands so as to \t”); If i and j are positive integers, does (-i)/j always have the same value as –(i/j)? Justify your answer. [2 points] printf(“fill the time \n”); Supply parenthesis to show how a C compiler would interpret the following expressions: [2 points] a * b – c *d +...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT