answer.
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
frosja888 [35]
1 year ago
11

Consider the following skeletal C program: void fun1(void); /* prototype */ void fun2(void); /* prototype */ void fun3(void); /*

prototype */ void main() { int a, b, c; . . . } void fun1(void) { int b, c, d; . . . } void fun2(void) { int c, d, e; . . . } void fun3(void) { int d, e, f; . . . } 256 Chapter 5 Names, Bindings, and Scopes Given the following calling sequences and assuming that dynamic scoping is used, what variables are visible during execution of the last function called? Include with each visible variable the name of the function in which it was defined. a. main calls fun1; fun1 calls fun2; fun2 calls fun3. b. main calls fun1; fun1 calls fun3. c. main calls fun2; fun2 calls fun3; fun3 calls fun1. d. main calls fun3; fun3 calls fun1. e. main calls fun1; fun1 calls fun3; fun3 calls fun2. f. main calls fun3; fun3 calls fun2; fun2 calls fun1
Computers and Technology
1 answer:
natita [175]1 year ago
8 0

Answer:

Check the explanation

Explanation:

a) main calls fun1; fun1 calls fun2; fun2 calls fun3

fun3()                                        d, e, f

fun2()                                        c, d, e

fun1()                                        b, c, d

main()                                        a, b,c

CALL STACK SHOWING THE VARIABLES OF EVERY FUNCTION

   From the above call stack diagram, it is very clear that the last function call is made to fun3().

   In fun3(), the local variables "d, e, f" of fun3() will be visible

   variable "c" of fun2() will be visible

   variable "b" of fun1() will be visible

   variable "a" of main() will be visible

b) main calls fun1; fun1 calls fun3

fun3()                                        d, e, f

fun1()                                        b, c, d

main()                                        a, b,c

CALL STACK SHOWING THE VARIABLES OF EVERY FUNCTION

   From the above call stack diagram, it is very clear that the last function call is made to fun3().

   In fun3(), the local variables "d, e, f" of fun3() will be visible

   variable "b, c" of fun1() will be visible

   variable "a" of main() will be visible

c) main calls fun2; fun2 calls fun3; fun3 calls fun1

fun1()                                        b, c, d

fun3()                                        d, e, f

fun2()                                        c, d, e

main()                                        a, b,c

CALL STACK SHOWING THE VARIABLES OF EVERY FUNCTION

   From the above call stack diagram, it is very clear that the last function call is made to fun1().

   In fun1(), the local variables "b, c, d" of fun1() will be visible

   variable "e, f" of fun3() will be visible

   variable "a" of main() will be visible

d) main calls fun1; fun1 calls fun3; fun3 calls fun2

fun2()                                        c, d, e

fun3()                                        d, e, f

fun1()                                        b, c, d,

main()                                        a, b,c

CALL STACK SHOWING THE VARIABLES OF EVERY FUNCTION

   From the above call stack diagram, it is very clear that the last function call is made to fun2().

   In fun2(), the local variables "c, d, e" of fun2() will be visible

   variable "f" of fun3() will be visible

     variable "b" of fun1() will be visible

   variable "a" of main() will be visible

The last function called will comprise of all its local variables and the variables other than its local variables from all its preceding function calls till the main function.

You might be interested in
Taylor and Rory are hosting a party. They sent out invitations, and each one collected responses into dictionaries, with names o
disa [49]

Answer:

Following are the code to this question:

def combine_guest(guest1, guest2):#defining a method combine_guest that accepts two dictionary

   guest2.update (guest1)#use dictionary guest2 that use update method to update guest2 dictionary

   return guest2#return guest2 dictionary values

Rory_guest= { "Ada":2, "Ben":3, "Dav":1, "Jo":3, "Charry":2, "Terry":1, "bob":4}#defining a dictionary and add value

Taylor_guest = { "Dav":4, "Nan":1, "bobert":2, "Ada":1, "Samantha":3, "Chr":5}#defining a dictionary and add value

print(combine_guest(Rory_guest,Taylor_guest))#calling the combine_guest method

Output:

{'Nan': 1, 'Samantha': 3, 'Ada': 2, 'bob': 4, 'Terry': 1, 'Jo': 3, 'Ben': 3, 'Dav': 1, 'Charry': 2, 'bobert': 2, 'Chr': 5}

Explanation:

In the code a method, "combine_guest" is defined, that accepts two dictionaries "guest1, guest2" inside the method, in which the "guest2" dictionary uses the update method to combine the value of the guest1 dictionary and use a return keyword to return guest2 values.

In the next step, two dictionaries are declared, that holds some values and use a print method to call the "combine_guest" method and prints its return values.  

7 0
1 year ago
In this programming assignment, you will create a hierarchy of classes (see below) that inherit from the beverage class. The bas
harina [27]

Answer:

public class GetInfo{

Beverage[]  beverages=new Beverage[100];

int i=0;

GetInfo(Beverage b){

beverages[i]=b;

i++;

}

public void Display(){

for(int i=0;i<beverages.length;i++)

cout<<beverage[i].tostring();

}

Explanation:

we are taking Beverages array to store all values and in constructor we are adding that to the list and Display() function prints the vale

5 0
1 year ago
Adele’s mother owns a Daycare and she wants to learn all about this business, to help her mom and own it one day. Which CTSO sho
Gennadij [26K]

Answer:

She should join the Future Business Leaders of America–Phi Beta Lambda

Explanation:

CTSOs are Career and technical student organizations. These organizations are vocational and extracurricular groups based primarily in high schools, colleges and career technological centres, for students in Career and Technical Education. They are important parts of the high school and college programs.

The Future Business Leaders of America–Phi Beta Lambda prepares students to become community-minded business leaders. It provides opportunities to learn career skills and gain leadership experience.

Therefore Adele should pick this CTSO

7 0
2 years ago
What three things in the third generation of computing helped get programming enthusiasts more involved with computers? Select 3
andrew11 [14]

Answer:

ipods, windows 10,intengrated circut

Explanation:

5 0
2 years ago
Read 2 more answers
For the (pseudo) assembly code below, replace X, Y, P, and Q with the smallest set of instructions to save/restore values on the
Dimas [21]

Answer:

Explanation:

Let us first consider the procedure procA; the caller in the example given.

  Some results: $s0,$s1,$s2, $t0,$t1 and $t2 are being stored by procA. Out of these registers, few registers are accessing by procA after a call to procB. But, procB might over-write these registers.

       Thus, procA need to save some registers into stack first before calling procB, .

      only $s1,$t0 and $t1 are being used after return from procB in the given example,

       Caller saves and restores only values in $t0-$t9, according to MIPS guidelines for caller-saved and callee-saved registers, .

       Thus, procA needs to save only $t0 and $t1.

    jal instruction overwrites the register $ra by writing the address, to which the control should jump back, after completing the instructions of procB, when procB is called,.

       Therefore, procA also need to save $ra into stack.

 ProcA is writing new values into $a0,$a2, procA must save $a0 and $a1 first before calling procB, .

     In the given example, after return from procB, only $a0 is being used. It is therefore enough to save $a0.

   Also, procA needs to save frame pointer, which points the start of the stack space for each procedure.

       Generally, as soon as the procedure begins, frame pointer is set to the current value of the stack pointer,.

Let us consider the procedure procB; the callee in the given example.

 The callee is responsible for saving values in $s0-$s7 and restoring them before returning to caller, this is according to MIPS guidelines for caller-saved and callee-saved registers,

   procB is expected to over-write the registers $s2 and $t0. Nonetheless, in the first two lines, procB might over-write the registers $s0 and $s1.

   Thus, procB is responsible for saving and restoring $s0,$s1 and $s2.

X:

We need to create space for 5 values on the stack since procA needs to save $a0,$ra,$t0,$t1 and $fp(frame pointer), . Each value(word) takes 4 bytes.

$sp = $sp – 20 # on the stack, create space for 5 values

sw $a0, 16($sp) # store the result in $a0 into the memory address

               # indicated by $sp+20

sw $ra, 12($sp) # save the second value on stack

sw $t0, 8($sp) # save the third value on stack

sw $t1, 4($sp) # save the fourth value on stack

sw $fp, 0($sp) #  To the stack pointer, save the frame pointer

$fp = $sp      #  To the stack pointer, set the frame pointer

Y:

lw $fp, 0($sp) #  from stack, start restoring values

lw $t1, 4($sp)

lw $t0, 8($sp)

lw $ra, 12($sp)

lw $a0, 16($sp)

$sp = $sp + 20 # decrease the size of the stack

P:

$sp = $sp – 12 #  for three values, create space on the stack

sw $s0, 0($sp) # save the value in $s0

sw $s1, 0($sp) # save the value in $s1

sw $s2, 0($sp) # save the value in $s2

Q:

lw $s0, 0($sp) #  from the stack, restore the value of $s0

lw $s1, 0($sp) #  from the stack, restore the value of $s1

lw $s2, 0($sp) #  from the stack, restore the value of $s2

$sp = $sp + 12 # decrease the stack size

8 0
1 year ago
Other questions:
  • In the game Beehive, you play the role of a worker bee who must watch over her hive. Your duties include (among others) directin
    12·2 answers
  • A U.S. social security number consists of a string of 9 digits, such as "444422333". Assume that input consists of a sequence of
    6·2 answers
  • With Voice over Internet Protocol (VoIP), _____. a. voicemails cannot be received on the computer b. call quality is significant
    6·1 answer
  • You just got a shipment of 10 network-attached laser printers. You want these printers to always have the same address but you w
    12·1 answer
  • ANSWER AS SOON AS POSSIBLE: When I try to join roblox adopt me it says: "Roblox Datastore servers are currently down. Please rej
    10·2 answers
  • Consider the following 3-PARTITION problem. Given integers a1; : : : ; an, we want to determine whether it is possible to partit
    10·1 answer
  • Your employer, yPlum Corporation is manufacturing two types of products: Mirabelle smartphone, and Blackamber laptop. The compan
    14·1 answer
  • A company with a large number of hosts creates three subdomains under a main domain. For easier management of the host records,
    11·1 answer
  • Consider the packets exchanged in TCP connection setup between Host A and Host B. Assume that Host A's initial sequence number i
    7·1 answer
  • [20 points] 3.3 Code Practice: Question 2
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!