variable attributes (6)
identifier of the variable
name
true or false:
variables must always have names
false, variables can be temporary or anonymous objects that don’t have a name
the memory location associated with the variable at current time
address
true or false:
when recursion is employed, the same local variable name can have multiple address during execution
true
it happens when two or more identifiers refer to the same address
aliases
in this code snippet, what is b?
int a = 5; int *b = &a;
b is an alias of a
what will be the result of the code snippet below:
int a = 5;
int *b = &a;
*b = 9;
printf("a = %d, *b = %d\n", a, *b);a = 9; *b = 9
the set of values valid for a specific variable is defined by this attribute
type
the operations that are legal/defined are set by this attribute
type
sometimes, the size/format of the variable is defined/set by this attribute
type
the bits stored in memory cells
value
the memory is also modeled as __
abstract cells
refers to the location you need to write
L-value
refers to the data contents you read
R-value
in the code snippet below, what does x and y+1 refer to?
x = y+1;
x: x’s L-value
y+1: x’s R-value
refers to the activation to deactivation
lifetime
the time during which the variable is bound to a specific memory location
lifetime
step-by-step process of how lifetime works (5)
the region of a program’s source code where a particular variable/name is visible and can be accessed
scope
what type of scope does int a = 5; have?
int a = 5;
int main() {
int a = 2;
{
int a = 3;
}
}global scope
what type of scope does int a = 2; have?
int a = 5;
int main() {
int a = 2;
{
int a = 3;
}
}local scope
what type of scope does int a = 3; have?
int a = 5;
int main() {
int a = 2;
{
int a = 3;
}
}block scope
association between an attribute and entity
bindings