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
frosja888 [35]
2 years 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]2 years 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
Create a class, using separate files, named DynamicGrades. (2 points) This class has three data members: an int that represents
Alex

Answer:

See explaination

Explanation:

#include <iostream>

using namespace std;

//DynamicGrades.h

class DynamicGrades

{

public:

DynamicGrades(int size);

~DynamicGrades();

void mutate(int studentId, int index, int grade);

int getGrade(int studentId, int index);

private:

int m_studentId;

int m_noofGrades;

int* m_dynamicArr;

};

//DynamicGrades.cpp

#include "DynamicGrades.h"

DynamicGrades::DynamicGrades(int size)

{

m_noofGrades = size;

m_dynamicArr = new int[m_noofGrades] {0};

}

DynamicGrades::~DynamicGrades()

{

if(nullptr != m_dynamicArr)

delete[] m_dynamicArr;

}

void DynamicGrades::mutate(int studentId, int index, int grade)

{

m_studentId = studentId;

if (index < m_noofGrades)

m_dynamicArr[index] = grade;

}

int DynamicGrades::getGrade(int studentId, int index)

{

if (index >= m_noofGrades)

return -1;

return m_dynamicArr[index];

}

//Main.cpp

#include "DynamicGrades.h"

int main()

{

DynamicGrades* grade = new DynamicGrades(5);

DynamicGrades grade2(10);

for (int i = 0;i < 5;++i)

{

grade->mutate(2, i, i + 1);

}

for (int i = 0; i < 10; i++)

{

grade2.mutate(3, i, i + 1);

}

cout << "Grades are " << endl;

for (int i = 0;i < 5;++i)

{

cout << grade->getGrade(2, i) <<" ";

}

cout << endl;

for (int i = 0; i < 10; i++)

{

cout << grade2.getGrade(3, i) << " ";

}

}

3 0
3 years ago
What is the value of y when this code executes?
Cerrena [4.2K]

Answer:

The operation of 6*x only executes if x is greater or equal to 0, since x=-10 and -10 is less than 0, the operation does not execute. For this reason,  the value of y using this code is None.

Explanation:

In python a function is defined with the syntaxis:  

def function(x):  

the operation to execute (x)

value to return

In this case, the function is foo and the parameter is x:  

def foo(x):

  if x>= 0:

     return 6*x

The code starts by assigning a value to x. Then, the code asks if the value of x is grater or equal to 0, if this condition is meet, then the code returns the value of 6 times x, if not, then the code does not return a value. In this case, x is -10 and this value is not grater or equal to 0. Given that the condition is not met, then the code stops executing and the value of y is none.

4 0
3 years ago
On the first line, place your name in a comment. Create a program that does the following: Take in three integer numbers from th
Helen [10]

Answer and Explanation:

//buchi

Var firstNumber=prompt("please enter first number");

Var secondNumber=prompt("please enter second number");

Var thirdNumber=prompt("please enter third number");

Var numberTotal=firstNumber+secondNumber+thirdNumber;

Function calculateNumbers(){

return numberTotal;

return int(numberTotal/3);

return firstNumber*secondNumber*thirdNumber;}

Console.log(calculateNumbers());

8 0
3 years ago
Need answer ASAP
kaheart [24]

Answer:

D. To ensure that the software adheres to technical standards

Explanation:

The responsibility of the software architect is to ensure that all parts of the software system are able to meet the requirements set forth by the project or specifications, in this case, the technical standards.  This is an important piece of the software system because without it, the software system may not perform the necessary functions that it was written to do.

Cheers.

5 0
2 years ago
You can use the ____ command to delete an entire table and its data.?
jek_recluse [69]
You can press control and x at the same time, the delete button, or backspace
6 0
3 years ago
Other questions:
  • 1. A video card on a modem motherboard would run best in which type of slot?
    10·1 answer
  • Powerpoint assumes that the first slide in a new presentation is the
    10·1 answer
  • Once you select select a crop boundary, you can no
    15·1 answer
  • Antivirus software uses ________ to search for known viruses.
    9·1 answer
  • Which of the following is the code of acceptable behaviors users should follow while on the Internet; that is, it is the conduct
    15·1 answer
  • 7.) Title text boxes on every slide must be the same format. <br> A. True <br> B. False
    15·2 answers
  • How does abstraction help us write programs
    11·1 answer
  • The different generation of computer explain in breif?​
    7·2 answers
  • Which is an example of a demand account
    10·1 answer
  • A(n) _____ is a computerized system by which subscribers are able to communicate to all other subscribers by sending a transmiss
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!