Variables in C++ - Reading Assignment

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

  2. The definition of a variable is its creation.

  3. The instantiation of a variable is its creation along with its assignment.

  4. An I-value is an object that occupies and identifiable location in memory (e.g.: a variable).
    An r-value is an expression that is not an I-value.

  5. An uninitialized variable is a variable that has been defined without giving it a starting value.
    An unitialized variable can cause crashes and unpredictable behaviour of the program when
    executed.

  6. Undefined behaviour can be the consequence of executing a bad-coded program.
    The output resultof the program is unpredictable and can change every time the program is
    executed.

1 Like

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

2. What is Definition of a variable?
Specifying a type and a name for a variable for example

3. What is Instantiation of a variable?
Allocation of memory in RAM for a variable

4. What is the difference between an l-value and an r-value?
An l-value has a persistent address. An r-value hasn’t a persistent address.

5. What is an uninitialized variable and what kind of behaviour can you expect from such a variable?
An uninitialized variable is in memory, but she doesn’t have value assigned to it. Using such a variable can cause unexpected behavior.

6. What is undefined behaviour?
Undefined behavior is when the result of the program may exhibit unexpected results. He can work well the three first executions and not at the fourth for example.

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

2… What is the Definition of a variable?
A declaration statement like int x; which defines the variable x to be an integer.

  1. What is Instantiation of a variable?
    At runtime an object is created and assigned a memory address.
  2. What is the difference between an l-value and an r-value?
    left value and right value of expression
    left value has a memory address, right value has no memory address and is discarded after assignment
  3. What is an uninitialized variable and what kind of behavior can you expect from such a variable?
    An unitialized variable has not been given a value, not by definition nor by assignment. When displaying the variable, It may give whatever value was still stored in the memory address or may give a compile error. This is called undefined behavior.
  4. What is undefined behavior?
    The result of executing code that is not well defined by the language. You never know what you’re going to get, it may be anything, including the correct solution.
1 Like

1.) a way to store data like store 1 to the variable “A”. Then you can recall “A” and get back the value of 1.

2.) A way to store and retrieve information in a program.

3.) to a create a new instance of a variable

4.) It has to do with the direction in which are evaluated (was not covered in article)

5.) It’s a variable that has not been assigned a “mailbox number” or type. The compiler will not know what type it is and stop compiling until you define it.

6.) It when there is an error in the code that the compiler does not catch but the code can still execute without failing. The results are unpredictable because variables might be unset or could have any value.

1 Like
  1. A Variable is an object that has a name. This object is a piece of memory that is allocated to store values.
  2. It’s a memory that has a name and is currently defined.
  3. It happens when the peace of memory is set a space in the RAM.
  4. An I-value is a variable that has a persistent address in memory and r-value is not associated with a persistent memory address.
  5. It’s a variable that has no memory location.
  6. Unpredictable behavior results.
1 Like
  1. A variable in C++ is object and an object is a region of storage

  2. A special kind of declaration statement

  3. It means an object will be created and assigned to a memory address

  4. Can’t find it in the article
    (4. I have a standard memory area, r doesn’t)

  5. ?

  6. Error code

1 Like

Did you check online? Most students don’t have issues finding the answers themselves. :wink:

Its a variable with no location reserved in memory.

It results in undefined behavior which might end up in errors in the program. :slight_smile:

  1. A named object.

  2. Memory location to hold value of a object.

  3. Reserving the memory slot for the object

  4. I-value is assigned to the memory and more persistent, r-value is temporary and discarded after the statement has been made.

  5. Its a variable that has not been given a value. If it used there can be anything assigned to that spot at the time.

  6. What would happen if you used uninitialized variables, you don’t know what you get, because C++ has no rules what would happen. Everything has to be define.

1 Like
  1. It’s a named object. This is a region of storage that holds a value.
  2. It is a declaration statement that creates a variable.
  3. It means that when the code runs, the object will be created and assigned a memory address.
  4. I-values have a place in memory, r-values don’t.
  5. An uninitialized variable is in the memory but doesn’t have a value assigned to it. Using such a variable could cause unexpected results.
  6. The behavior might work or it might not
1 Like

1. What is a variable in C++?

  • In C++ named Objects are called variables and they are a region of storage.

2. What is the Definition of a variable?

  • A variable starts with declaration of the data type (i.e. Int), folllowed by identifier and assigned value.

3. What is Instantiation of a variable?

  • Instantiation means an Object will be created and assigned to a memory address.

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

  • An lvalue (locater value) points to a certain memory location, whereas an rvalue is an expression that does not represent an Object occupying some identifiable location in memory.

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

  • An uninitialized variable is a named variable without assigned value and you can expect undefined behavior from it.

6. What is undefined behavior?

  • When a variable has no assigned value it is unpredictable and unusable. It might even behave differently every time the program is run.
1 Like
  1. In C++, a variable is a named object used for storing value in memory.
  2. A definition is a kind of declaration statement used to create a variable.
  3. During runtime, instantiation is the process used to create an object and assign a memory address to it.
  4. l-values (left) are any values that can be on the left side of an assignment statement, meaning any value with an address in memory. r-values (right) are the values which can be on the right side of an assignment statement, meaning any statement that can be assigned to an l-value. An r-value could be a literal, a variable, or an expression, and needs to be evaluated as it is assigned to the l-value.
  5. An uninitialized variable is a variable that hasn’t had any value assigned to it yet. Because of that it is unpredictable and a bad idea.
  6. Output of a program with undefined behavior is unpredictable.
1 Like
  1. A variable in C++ is a named object – is a container for storing data values.
  2. A definition is a special kind of declaration statement used for variable creation.
  3. Instantiation means that the object will be created and assigned a memory address.
  4. An l-value (locator value) represents an object that occupies some identifiable location in memory (i.e. has an address). R-values are defined by exclusion. Every expression is either an l-value or an r-value, so, an r-value is an expression that does not represent an object occupying some identifiable location in memory.
  5. An unitialised variable is a variable that has not yet been given a value (by initialisation or assignment) and therefore has an unknown value assigned to it.
  6. Undefined behaviour is the result of executing poorly defined code. This could cause the program to return different results each time it is run, return consistently incorrect results, return inconsistent results or crash the program, etc.
1 Like
  1. a named object
  2. a place where you store data in the momeory of the computer
  3. We define a variable so that the computer knows where to store and where to look for the data.
  4. An lvalue is something that points to a specific memory location. On the other hand, a rvalue is something that doesn’t point anywhere. A variable has a specific memory location, so its an lvalue . C++ states that an assignment requires an lvalue as its left operand: this is perfectly legal.
  5. An uninitialized variable is a variable that has not been given a value by the program, using the value stored in an uninitialized variable will result in undefined behavior
  6. it is a symathic or a syntax error so that the program cannot assign a value
1 Like
  1. What is a variable in C++?
    a value stored in memory

  2. *What is Definition of a variable?
    a reserved space in memory with a unique identifier to be called on later

  3. What is Instantiation of a variable?
    Assigning a name to specific location in memory to be accessed later.

  4. What is the difference between an l-value and an r-value?
    l-value is basically the variable name or the name of the location in memory. r-value is the actually value stored at that location in memory.

  5. What is an uninitialized variable and what kind of behaviour can you expect from such a variable?
    A variable that has been declared (assigned to a designated space in memory) but not had a value assigned. Anything could be in the space as the act of declaration does not clear that memory location of any previously used value. You can expect undefined behaviour when accessing an uninitialized variable as anything (garbage) could be in that space.

  6. What is undefined behaviour?
    Behaviour that is not well defined by c/c++, the result of accessing an uninitialized variable.

  • Your program produces different results every time it is run.
  • Your program consistently produces the same incorrect result.
  • Your program behaves inconsistently (sometimes produces the correct result, sometimes not).
  • Your program seems like its working but produces incorrect results later in the program.
  • Your program crashes, either immediately or later.
  • Your program works on some compilers but not others.
  • Your program works until you change some other seemingly unrelated code.
1 Like
  1. What is a variable in C++? A named object
  2. What is Definition of a variable? a declared input in memory that can be defined by a specific type and value
  3. What is Instantiation of a variable? When a variable is set aside reserved in RAM
  4. What is the difference between an l-value and an r-value? l-values have a persistent address in memory. r-values are not associated with a persistent memory address and are discarded at the end of the statement in which they occur.
  5. What is an uninitialized variable and what kind of behaviour can you expect from such a variable? with no defined type code would use last type in mem and could cause code issues
  6. What is undefined behaviour? Function or code that is not recognized by the curremt program language your using
1 Like

1)A variable in C++ is a named object
2)A Special kind of declaration statement
3)The assignment of the object to a memory address
4)An l-value points to a specific memory location. An r-value doesn’t point to anywhere and are temporary.
5)An uninitialized variable is a variable that has been declared but not assigned a definite value. Will cause errors or bugs in the program
6)A result of executing a program whose behavior is thought to be unpredictable.

1 Like
  1. A variable in C++ is a named object.
  2. A variable is an object that has been given a name or an identifier. This object is a code which has a value stored within it. Calling a variable allows for the computer to find the memory of the value.
  3. The instantiation of a variable is the act of storing the value of value of an assigned object under a value. This can only occur during the runtime of an application. When the code is run, the computer knows to store the value of that variable. That storing of value is called the instantiation of a variable.
  4. R- values are values without an address or saved in memory, they are discarded after a statement but can be used to assign value to an l-value which is stored and has an address.
  5. An uninitialized variable is a variable that has no assigned value. By calling an variable with no assigned value, you can expect for the computer to fetch a random value which may have been located at that storage address previously. A random value could be presented.
    6.Undefined behavior is what results when you use an uninitialized variable. Undefined behavior can result in your program producing different outputs each time it is run. It can do things like producing different outputs each time it is run, crash, or even produce the correct output you are asking. The point is that by using uninitialized variables you can expect undefined behavior which can produce random results.
1 Like
  1. is a named region in memory
    2.is a a special kind of declaration statement
    3.Instantiation is a fancy word that means the object will be created and assigned a memory address.
    4.i-values have their place in memory , r values need to associate with a memory address
    5.unpredictable behavior
    6.is a behavior of a variable who is not well defined.
1 Like
  1. What is a variable in C++? It is an object with a name
  2. What is Definition of a variable? A variable is a named region of memory.
  3. What is Instantiation of a variable? It is an object which was created and assigned to a memory address.
  4. What is the difference between an l-value and an r-value? The r-value is a value and the l-value is an object reference
  5. What is an uninitialized variable and what kind of behaviour can you expect from such a variable? A variable without a value, it means it was not initialiced
  6. What is undefined behaviour? Haha it ist he nightmare of very programmer J
    In other words, when you can not be sure what will happen.
1 Like
  1. A named object
  2. A special kind of declaration statement for a variable, specifying name and type.
  3. It means the object will be created and assigned a memory address.
  4. An l-value is something that points to a specific place in memory, while r-values point nowhere. r-values are generally short lived and temporary, while l-values live longer because they exist as variables.
  5. An uninitialized variable is a declared variable that has not been given a value. Using such variables can lead to undefined behavior.
  6. Unpredictable behavior that can possibly render the program meaningless if certain rules of the language are broken.
1 Like