Variables in C++ - Reading Assignment

  1. What is a variable in C++?

It is a named region of memory
2. What is Definition of a variable?

Declaration statement used to create a variable.

  1. What is Instantiation of a variable?

Creating and assigning the memory location on runtime by the program when interprets the compilation code

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

r-value is a temporary value that does not persist beyond the expression, l-value persists.

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

The value in an uninitialized variable can be anything. It can exhibit undefined behavior

  1. What is undefined behaviour?

When the program does not compile correctly, crashes, generates incorrect results or fails to compile.

1 Like
  1. named object
  2. the declaration of the type of variable it is
  3. assignment of value at creation
  4. l-value has a persistent address whilst r-value does not. r-values can’t be on the left side of the ā€œ=ā€ as a result.
  5. Simply a reserved space of memory for the declared object of data. The variable can be assigned data at a later point and can change.
  6. The result of poorly defined execution behavior of the code resulting in unexpected behavior
1 Like

1. What is a variable in C++?
Variable are containers for story data values, it is declared by a type and a value
textvariableName = value;

2. What is Definition of a variable?
A variable is nothing but a name given to a storage area that our programs can manipulate. Each variable in C has a specific type, which determines the size and layout of the variable’s memory; the range of values that can be stored within that memory; and the set of operations that can be applied to the variable.

3. What is Instantiation of a variable?
When the program is run (started), the variable will be instantiated. Instantiation is a term that means the object will be created and assigned a memory address. Variables must be instantiated before they can be used to store values

4. What is the difference between an l-value and an r-value?
An lvalue refers to an object that persists beyond a single expression. An rvalue is a temporary value that does not persist beyond the expression that uses it

5. What is an uninitialized variable and what kind of behaviour can you expect from such a variable?
An uninitialized variable is a variable that has not been given a value by the program (generally through initialization or assignment). Using the value stored in an uninitialized variable will result in undefined behaviour.

6. What is undefined behaviour?
An undefined behaviour means that when the program fails to compile, or it may execute incorrectly, either crashes or generates incorrect results, or when it may fortuitously do exactly what the programmer intended.

1 Like
  1. A variable is a named object in C++.
  2. A definition of a variable is a declaration statement.
  3. Instantiation of a variable is the creation of the variable in the memory address.
  4. L-value is defined in memory, while r-value isn’t.
  5. Uninitialized variable has not been given a value, which can create unexpected results.
  6. Undefined behavior is a result of executing non-well-defined code.
1 Like
  1. What is a variable in C++?

an named object

A variable is a named region of memory.

  1. What is Definition of a variable?

  2. What is Instantiation of a variable?
    a process too create the value

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

its determined by the value sign
5. What is an uninitialized variable and what kind of behaviour can you expect from such a variable?
declared but not instantiated behavior

  1. What is undefined behaviour?

when the program fails to compile, or it may execute incorrectly, either crashes or generates incorrect results, or when it may fortuitously do exactly what the programmer intended .

2 Likes

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

2. What is the Definition of a variable?
The variable gets declarared and the type needs to be specified.

3. What is Instantiation of a variable?
When the programm gets executed, the variable that got declared is assigned to specific RAM location.

4. What is the difference between an l-value and an r-value?
l-values have persistent address values in memory, usually used for variable names
r-value is not associated with a persistent memory address.
Instead it refers to the value of a temporary address that is discarded once it deployed.

5. What is an uninitialized variable and what kind of behavior can you expect from such a variable?
The uninitialized variable has no value but it refers to a value from previous session.
it can give unexspected results and errors.

6. What is undefined behavior?
Undefined behavior is the result of executing code with undefined varaiables.

2 Likes

1. What is a variable in C++?

In C++, a variable is a named object, used to access a certain region of the memory.

2. What is Definition of a variable?

A variable is an object used to store some kind of information depending on it’s Data Type. The Data Type defines what Type of varible the program is dealing with (interger, double, string, boolean, etc)

3. What is Instantiation of a variable?

Instantion of a variable is the declaration of the variable during ā€œruntimeā€, where a Instance will be created in memory. To declare a variable, we need to declare it’s type and it’s name (Identifier).

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

An l-value is reffered to an object that that points to a specific memory location. An r-value is a value that doesn’t point anywhere.

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

An uninitialized variable is a variable that hasn’t given a known value. That variable will be given a value during the execution of the program, and can have some unexpected behavior.

6. What is undefined behaviour?

Undefined behavior is the result of executing code whose behavior is not well defined by the language.

2 Likes
  1. What is a variable in C++? it is an object.
  2. What is the Definition of a variable? it is basically a named object witch is called also called an identifier for example.
  3. What is Instantiation of a variable? is a fancy word that means the object will be created and assigned a memory address
  4. What is the difference between an l-value and an r-value? an I-value would have a persistant adress for example, an R-value doest not have a persistent adress
  5. What is an uninitialized variable and what kind of behavior can you expect from such a variable? an unintialized variable is in the memory but does not have a value assigned to it using it could cause unexpected behavior thats forsure.
  6. What is undefined behavior? would be an unpredicted behavior resulting from the use of unitialised variables would be random behavior
2 Likes
  1. What is a variable in C++?

A variable in C++ is a named object

  1. What is the Definition of a variable?

The Definition of a variable is a special kind of declaration statement

  1. What is Instantiation of a variable?

Instantiation means the object will be created and assigned a memory address. Variables must be instantiated before they can be used to store values.

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

lvalue – points to a specific memory location

rvalue – doesn’t point to anywhere

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

An uninitialized variable is that is declared, but is not set to a definite known value before it is used. It can cause unexpected errors or different kinds during execution

  1. What is undefined behavior?

Undefined behavior is when the program fails to compile, execute incorrectly, crashes, or generates incorrect results. When the result of the executing program is unpredictable, it is said to have undefined behavior.

1 Like
  1. A variable is the representation of a named object. An object is a region of storage, usually inside the computer memory, which contains a value and other associated parameters.

  2. The definition of a variable is a declaration statement through which a variable is named and through which a specific type of data is assigned to it.

  3. Instantiation is the process through which an object is created and assigned a memory address.

  4. An lvalue points to a specific memory location, like a variable, while an rvalue is something that does not point anywhere. Generally speaking, rvalues are temporary and short lived.

  5. An uninitialized variable is a variable that has not been given a known value (through initialization or assignment). While initialization means that an object was provided with an initial value at the point of definition, uninitialized means the object has not been given a known value. You can expect a randome behaviour as the program will return whatever value is residing in the memory location where the variable resides at the time of execution.

  6. Undefined behaviour is the result of executing code whose behaviour is not well defined by the C++ language, which has no rules determining what happens if the value of a variable that has not been given a known value is used. In this case, the program can produce different results every time it is run, produce the same incorrect result, can behave inconsistently, the progran can crash, work on some compilers but not in others, etc. It is not possible to know what result to expect.

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

  2. What is the Definition of a variable?
    a named object that can store a value

  3. What is Instantiation of a variable?
    when a value is created and stores a piece of data

  4. What is the difference between an l-value and an r-value?
    l-values contain memory that is persistent while r-values don’t contain persistent memory

  5. What is an uninitialized variable and what kind of behavior can you expect from such a variable?
    A variable with no value, many different problems can occur due to an uninitialized variable

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

1 Like

1. What is a variable in C++?

A variable is a named region of memory that can be used to store values.
A variable defines the object with a variable name and assigns the data type associated with it in some space in computer memory.

2. What is Definition of a variable?

In order to create a variable, we use a special kind of declaration statement called a definition.

3. What is Instantiation of a variable?

When the program is run (called runtime), the variable will be instantiated. Instantiation means the object will be created and assigned a memory address. Variables must be instantiated before they can be used to store values. For the sake of example, let’s say that variable x is instantiated at memory location 140. Whenever the program uses variable x, it will access the value in memory location 140. An instantiated object is sometimes called an instance.

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

L-valueā€ refers to a memory location that identifies an object. ā€œr-valueā€ refers to the data value that is stored at some address in memory.

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

An uninitialized variable is a variable that has not been given a value by the program (generally through initialization or assignment). Using the value stored in an uninitialized variable will result in undefined behavior.

6. What is undefined behaviour?

Undefined behavior means when the program fails to compile, or it may execute incorrectly, either crashes or generates incorrect results, or when it may fortuitously do exactly what the programmer intended. Whenever the result of an executing program is unpredictable, it is said to have undefined behavior.

1. What is a variable in C++?

A variable is a named region of memory that can be used to store values.
A variable defines the object with a variable name and assigns the data type associated with it in some space in computer memory.

2. What is Definition of a variable?

In order to create a variable, we use a special kind of declaration statement called a definition.

3. What is Instantiation of a variable?

When the program is run (called runtime), the variable will be instantiated. Instantiation means the object will be created and assigned a memory address. Variables must be instantiated before they can be used to store values. For the sake of example, let’s say that variable x is instantiated at memory location 140. Whenever the program uses variable x, it will access the value in memory location 140. An instantiated object is sometimes called an instance.

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

L-valueā€ refers to a memory location that identifies an object. ā€œr-valueā€ refers to the data value that is stored at some address in memory.

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

An uninitialized variable is a variable that has not been given a value by the program (generally through initialization or assignment). Using the value stored in an uninitialized variable will result in undefined behavior.

6. What is undefined behaviour?

Undefined behavior means when the program fails to compile, or it may execute incorrectly, either crashes or generates incorrect results, or when it may fortuitously do exactly what the programmer intended. Whenever the result of an executing program is unpredictable, it is said to have undefined behavior.