Variables in C++ - Reading Assignment

Variables are objects.
2.
A variable is a named region of memory.
3.
Instatation means that the object will be created and assigned a memory address.
4.
l-value points to a specific memory location

r-value refers to data value that is stored at some address in memory
5.
It is a varialbe which has not been given name yet.
6.
Rsult of executing a code not well defined by C++ language.

1 Like
  1. What is a variable in C++?
    An object with a name

  2. What is the Definition of a variable?
    The declaration of the variable type

  3. What is Instantiation of a variable?
    The creation of an object and its assignment to a memory address

  4. What is the difference between an l-value and an r-value?
    An I-value has a persistent address in memory while an r-value is temporary and discarded at the end of the statement where they occur

  5. What is an uninitialized variable and what kind of behavior can you expect from such a variable?
    A variable that has been instantiated but not given a value

  6. What is undefined behavior?
    Undefined behavior occurs when executing code that is not well defined by the language.

1 Like
  1. A variable a named object.
  2. A defined variable is creating a variable.
  3. Instantiation is when you run the variable.
    4.I-value assigns and the r-value is the expression that determines the value.
  4. An uninitialized variable is one that is declared but not instantiated.
  5. Undefined behavior is when you do not have defined code.
1 Like
  1. A variable is a named object
  2. A variable is an object in C++ that can hold a value, it is stored in the RAM
  3. It is the declaration of a data type.
  4. In C++ an lvalue is something that points to a specific memory location. On the other hand, a rvalue is something that doesn’t point anywhere. In general, rvalues are temporary and short lived, while lvalues live a longer life since they exist as variables.
  5. The Variable has no value yet, Undefined behavior
  6. It means that the program’s behavior is unpredictable. it could crash or some compilers won’t be able to compile it. Output results could be different.
1 Like
  1. they are named regions of storage for values and other associated properties.
  2. they are named objects
  3. it is created and assigned a memory address
  4. I values have a memory address, while r values are temporary and not associated with a persistent memory address.
  5. uninitialized variables aren’t assigned a memory address. If they don’t have a memory address they can’t store value.
  6. using a value of an object that hasn’t been assigned a value (aka uninitialized variable)
1 Like
  1. A variable in C++ is a named object.
  2. A definition for a variable is a declaration that instructs the compiler to create the variable and to assign to that variable a specified name, data type and value if applicable.
  3. Instantiation of a variable is where the compiler creates the variable-object and assigns it a memory address at compile time.
  4. An l-value (such as a variable ‘x’) has a persistent address in memory that can be referred back to in the future. An r-value (such as int ‘10’) is a value that has no specific memory address.
  5. An uninitialized variable is a variable that has been created but not assigned a value. The code will run but the value of the uninitialized will be undefined behavior. It is not advised to leave the variable uninitialized because it can cause unpredictability when the variable is called.
  6. Undefined behavior occurs when code isn’t well defined. For example, it occurs when a variable is left uninitialized.
1 Like
  1. object to store value
  2. memory location that holds some values or text held in
  3. values saved in memory
    4.L-Value that is in memory R-Value something stored in memory
    5 declared but has no set value
    6.not clear
1 Like

A named object, an object being a region of memory. Therefore a variable is a memory location which can be referenced via it’s name rather than having to know it’s actual address in memory.

It is a declaration statement with syntax “ Type Identifier ” which creates a memory location, referenced by name “ Identifier ”, and that the value stored in that location is to be interpreted as data type “ Type ”.
This is the creation of an object and assignment of its memory location during runtime.

An l-value is a value that has a memory address. An r-value is an expression which evaluates to a value and does not qualify as an l-value.

An uninitialized variable is one which has not yet had a value assigned to it. Since most variables are not assigned a given value prior to initialization, an uninitialized variable could cause undefined behavior.

This is behavior which is unpredictable and could produce erroneous results.

1 Like
  1. What is a variable in C++?
    A named object.

  2. What is Definition of a variable?
    A piece of memory that has a name and is currently defined and may be defined and vary based on another piece of memory.

  3. What is Instantiation of a variable?
    The creation of an object and assignation to a memory address.

  4. What is the difference between an l-value and an r-value?
    l- value is used as named reference to memory location and r-value is evaluated for assignment purpose.

  5. What is an uninitialized variable and what kind of behaviour can you expect from such a variable?
    A variable that has not been given a known value (through initialization or assignment) is called an uninitialized variable. The default value of that variable is whatever value happens to already be in that memory location.

  6. What is undefined behaviour?
    The result of executing code whose behavior is not well defined by the language.

1 Like
  1. What is a variable in C++?
  2. What is the Definition of a variable?
  3. What is Instantiation of a variable?
  4. What is the difference between an l-value and an r-value?
  5. What is an uninitialized variable and what kind of behavior can you expect from such a variable?
  6. What is undefined behavior?

1: A variable in c++ is an object with a name.

2: The definition of a variable is the given name and type of the object and the memory it has been assigned to.

3: It’s the compiling time of a variable and its type. That is when a memory space is assigned to that variable

4: An lvalue is an expression that refers to an object. A rvalue is any expression that has a value, but cannot have a value assigned to it.

5: An uninitialized variable is a variable that is declared but is not set to a definite known value before it is used. It will have some value. As such, it is a programming error and a common source of bugs in software.

6: I don’t know how to define undefined behavior, because then it would be definable, wouldn’t it:)? My guess is that a lot can happen in the code which cannot be foreseen.

1 Like

:sweat_smile: can’t argue with that :smiley:

1 Like
  1. It is a named object.

  2. The variable is a named single piece of data in a region of storage.

  3. Instantiation is a object that will be created and assigned to a memory address.

  4. The lest most value in a code the l-value is the one who is assigned a memory address and the right most value the r-value provide an temporally initial value for the variable and is not save in a memory.

  5. A variable that has not been given a know value (assignment).

  6. It is a code or codes not define in the C++ programming language when you run them it give total random result.

1 Like
  1. A variable in C++ is a named object
  2. The definition is where you state the variable name and type.
  3. Instantiation is where the variable object is created and assigned a memory address.
  4. l-value is the memory address where a variable is stored and r-value is the value that is stored.
  5. An uninitialized variable may cause unpredictable results.
  6. An undefined behavior has not been defined by the language it’s used in.
1 Like
  1. Object with a name

  2. Variables are defined with a type and a name,

  3. Allocation of RAM

  4. l-value has a persistent address and r-value does not

  5. A Variable that has been defined but has not been given a known value.

  6. The result of executing code whose behavior is not defined by the language.

1 Like
  1. What is a variable in C++?
    object with a name

  2. What is the Definition of a variable?
    definitions is declaration statement used to create variable

  3. What is Instantiation of a variable?
    it means that object will be created and assigned a memory address

  4. What is the difference between an l-value and an r-value?
    l-value has a persistent address is memory (variables)
    r-value is not associated with a permanent memory address

  5. What is an uninitialized variable and what kind of behavior can you expect from such a variable?
    variable without value which lead to undefined behavior

  6. What is undefined behavior?
    result of executing code whose behavior is not well defined by the language

1 Like
  1. a named object
  2. a variable is a named region of memory. When we define a named and a type of the object.
  3. Is when an object is created and assign a memory address. Variable must be instantiated before we can used to store value. Also called “Instance”.
  4. An l-value has a persistent address. An r-value hasn’t a persistent address.
  5. When a uninitialized variable doesn’t have a value assigned.
  6. Is when the result of executing code is not well defined by the language.
1 Like
  1. A name given to a memory location, the basic unit of storage in a program.

  2. A named object - named region of storage (usually memory) that has a value and other associated properties.

  3. The object is created and assigned a memory address when the program is run.

  4. L-value is something that exists as a variable and points to a specific memory location, R-value doesn’t point anywhere and is temporary.

  5. A variable that has not been given a known value (usually through initialization or assignment). The default value of the variable assigned a memory location is whatever value happens to already be in that memory location.

  6. It is the result of executing code whose behavior is not well defined by the C++ language. The C++ language doesn’t have any rules determining what happens if you use the value of a variable that has not been given a known value.

1 Like
  • What is a variable in C++? A variable is a defined place to store values.
  • What is the Definition of a variable? A variable is a named piece of memory in which values can be stored.
  • What is Instantiation of a variable? Instantiation is assignment of a memory space to a variable.
  • What is the difference between an l-value and an r-value? An I value is assigned when the value is created, i.e. initialized. An r-value may be assigned later.
  • What is an uninitialized variable and what kind of behavior can you expect from such a variable? An uninitialized variable is one that has no value assigned. Any random value in memory might be assigned causing the program to fail.
  • What is undefined behavior? Undefined behavior means that the result may be right or wrong or some random result with no meaning.
1 Like
  1. What is a variable in C++?

A variable is a named region of memory.

  1. What is Definition of a variable?

A declaration statement used to create a variable.

  1. What is Instantiation of a variable?

Creating and assigning a memory address for an object.

  1. What is the difference between an l-value and an r-value?

An r-value refers to data value that is stored at some address in memory. A r-value is an expression that can’t have a value assigned to it which means r-value can appear on right but not on left hand side of an assignment operator (=). An l-value” refers to memory location which identifies an object. l-value may appear as either left hand or right hand side of an assignment operator(=).

  1. What is an uninitialized variable and what kind of behaviour can you expect from such a variable?

An uninitialized variable is a variable that is declared but is not set to a definite known value before it is used. The expected behavior for such a variable would that it would have a value declared at a later point in the program, perhaps by user input.

  1. What is undefined behaviour?

There are no restrictions on the behavior of the program. Examples of undefined behavior are memory accesses outside of array bounds, signed integer overflow, and null pointer dereferenced.

1 Like
  1. What is a variable in C++?
  • Its an object where memory is stored consisting of values.
  1. What is the Definition of a variable?
  • Named object
  1. What is Instantiation of a variable?
  • An object that’s created and assigned to a memory address
  1. What is the difference between an l-value and an r-value?
  • I-value: persistent address , r-value: not a persistent address
  1. What is an uninitialized variable and what kind of behavior can you expect from such a variable?
  • Value not assigned
  1. What is undefined behavior?
    -unexpected results
1 Like