A variable is a named memory location or memory cell. It is used to store program’s input data and its computational results during execution. The value of a variable may change during the execution of a program. However, the name of a variable cannot be changed.
The Variables are created in RAM. RAM is a temporary memory. That is why data stored in variables is also temporary. The data stored in a variable is automatically removed when the program is ends.
Name of a Variable: It is the name of memory which we reserve in RAM.
Value of a variable: It is representing which value we given to a variable.
Address of a variable: It is referring to the memory location of a variable.
The process of specifying the variable name and its type is known as variable declaration.
Some examples of declare wrong variables
The process of assigning a value of a variable at the time of its declaration is known as variable initialization.
data_type variable_name = value;
The data type defines set of values and the set of operation on those values. The data is process according to its data type and return the output. The data and its type are define before the designing of actual program. A C++ program has many data types. Each data type require different amount of memory. C++ language provides the following data types:
Integer data type is store only numeric values with no decimal and fraction point. It includes both positive and negative values.
C++ provides these types of integer values:
Floating data type is numeric value with decimal and fractional points. It is also known as Real data type.
Data Type Size in Bytes Description
The backslash is used as a marker character to tell the compiler that the next character has some special meaning. What that next character means is, up to the implementation. For Example, C-style languages use n to mean newline and t to mean tab. The use of the word “escape” really means to temporarily escape out of parsing the text and into another mode where the subsequent character is treated differently.
Types of Escape Sequences:
Below is the list of some usually used escape sequences in C++;
To understand the concept of escape sequence more precisely, consider the following sample program as an example.