Question

In: Computer Science

What is the binding time for the following in C/C++ program. Explain. a. The location of...

What is the binding time for the following in C/C++ program. Explain.

a. The location of memory of a local variable in a function.

b. The meaning of the keyword while

c. The size in memory of a variable of type int

d. The location in memory of a global static variable

e. The code for the printf function

f. The type of local variable in a function

g. The values assigned to a variable

h. The size in memory of a pointer

Solutions

Expert Solution

Binding is association of two or more attributes with names at a particular time .

Binding is done for each variable and functions.

In general, biding is done at

Static time: Variables, attributes, name are resolves at compile-time.

Dynamic time: Variables, attributes, name are resolves at run time.

a. The location in memory of a local variable in a method.
Dynamic Binding or Run time

When the method is invoked, a run time stack is created for called method which has activation record.
An activation record contains return address of calling method, parameters, local variables.
So local variables of a method have space allocated, when method is invoked at run time.


b. The meaning of the keyword while.
Language definition time- Static binding or Compile time.


c. The size in memory of a variable of type int
Language implementation time - Static binding or Compile time.
The compiler will need to know the size of integer to compute required memory. So the compiler computes this at compile time.


d. The location in memory of a global static variable.
Static Binding or Compile time
Any variable declared with global scope, static or extern variable will occupy memory at compile time.


e. The code for the printf function
Static Binding or Compile time

printf() function belongs to stdio.h, which is static library
For a static library, the actual code is extracted from the library by the linker and used to build the final executable at compile time. Library code is connected at compile time and hence code for printf function is also doing static binding.


f. The type of local variable in a function
Static binding or Compile time

Type checking is done by compiler only.


g. The values assigned to a variable
Dynamic binding or Run time.
Except constant variable, values of a variable are resolved at run time.


h. The size in memory of a pointer
Language implementation time.

The compiler will need to know the size of integer to compute required memory. So the compiler computes this at compile time.


Related Solutions

The following table gives temperature data in *C as a function of time of day and day of the week at a specific location.
The following table gives temperature data in *C as a function of time of day and day of the week at a specific location. Data are missing for the entries marked with a question mark (?). Use linear interpolation with MATLAB to estimate the temperature at the missing points.
Location A Location B Location C Location D 52                   75                &nb
Location A Location B Location C Location D 52                   75                  67                  58 59                   55                  77                  38 81                   95                  47                  82 63                   46                  74                  77 73                   85                  56                  91 Test the following hypotheses and also state the alternate hypothesis in each case. Write a sentence or two summarizing your conclusion after you have completed each hypothesis testing. Hypothesis 1 The average time spent per table in Location A is the same as the average time spent per table in Location B....
explain the distinction between binding site and binding region
explain the distinction between binding site and binding region
What are some of the conditions of a binding Contract? Please explain
What are some of the conditions of a binding Contract? Please explain
What features of the binding site hinder oxygen binding to Hb? What feature of the binding...
What features of the binding site hinder oxygen binding to Hb? What feature of the binding site facilitates oxygen binding to Hb? Explain the Bohr effect using the theory of allosteric modulation of oxygen binding to hemoglobin.
Can anyone clearly explain: 1. What is end-stacking binding mode in Triplex DNA binding? 2. How...
Can anyone clearly explain: 1. What is end-stacking binding mode in Triplex DNA binding? 2. How are the effects of the end-stacking when a ligand binds with a triplex DNA? 3. How is binding affinity involved in this case?
C++ Use BinaryNodeTree to solve the following questions in a program: 1) What is the value...
C++ Use BinaryNodeTree to solve the following questions in a program: 1) What is the value of the prefix expression +−∗ 235/↑ 2 3 4? 2) What is the postfix form of the expression ((x + y) ↑ 2) + ((x − 4)/3)? 3) What is the value of the postfix expression723 ∗ − 4 ↑ 9 3/+?
Program must be in C++! Write a program which: Write a program which uses the following...
Program must be in C++! Write a program which: Write a program which uses the following arrays: empID: An array of 7 integers to hold employee identification numbers. The array should be initialized with the following values: 1, 2, 3, 4, 5, 6, 7. Hours: an array of seven integers to hold the number of hours worked by each employee. payRate: an array of seven doubles to hold each employee’s hourly pay rate. Wages: an array of seven doubles to...
(LANGUAGE C++) This time, you will finish the program so that the user gets to solve...
(LANGUAGE C++) This time, you will finish the program so that the user gets to solve the puzzle. You will also use header files and introduce classes into your program. We will follow the draft start to how to incorporate classes. Here are the requirements: ·In the file quotes.h, define the Quotes class: o   Quotes(string filename) // a constructor to load quotes from the named file into a vector o   The vector should be a field of the class so it will...
Time Calculator Create a C++ program that lets the user enter a number of seconds and...
Time Calculator Create a C++ program that lets the user enter a number of seconds and produces output according to the following criteria: • There are 60 seconds in a minute. If the number of seconds entered by the user is greater than or equal to 60, the program should display the number of minutes in that many seconds. • There are 3,600 seconds in an hour. If the number of seconds entered by the user is greater than or...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT