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....
Write a C program in Unix which uses a function called search to find the location...
Write a C program in Unix which uses a function called search to find the location of a value in THREE arrays of floats. The function should take three parameters :          the value to be found          the array to be searched          the size of the array N.B.!!!! The main program should read in three arrays of varying size          example : array a has twelve elements                    array b has six elements                    array c has nine...
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.
In C program #include<stdio.h> Write a program that prompts the user to input the elapsed time...
In C program #include<stdio.h> Write a program that prompts the user to input the elapsed time for an event in seconds. The program then outputs the elapsed time in hours, minutes, and seconds. Example (Numbers with underscore indicate an input): Enter the elapsed time in seconds: 9630 The elapsed time in seconds = 9630 The equivalent time in hours:minutes:seconds = 02:40:30 HINT: Pay attention to the printf format descriptors.
using C program Assignment Write a computer program that converts a time provided in hours, minutes,...
using C program Assignment Write a computer program that converts a time provided in hours, minutes, and seconds to seconds Functional requirements Input MUST be specified in hours, minutes, and seconds MUST produce the same output as listed below in the sample run MUST correctly compute times Nonfunctional requirements MUST adhere to program template include below MUST compile without warnings and errors MUST follow the code template provided in this assignment MUST NOT change " int main() " function MUST...
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?
Write a C++ program to calculate the time to drain a cylindrical water tank for an...
Write a C++ program to calculate the time to drain a cylindrical water tank for an initial water height ranging from 1 to 10 feet (specifically for 1, 2, 4, 6, 8, and 10 ft). The tank has a radius (rt) of 2 feet and the drain radius (rd) is 0.3 inch. The gravitational constant (g) is 32.2 feet/sec2. The formula for time to drain the tank is time=(rtrd)2h/vavg where, average velocity, vavg=0.5(2gh).5 In your program, assign the values to...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT