C / C++ Variables
You should be able to remember about variables in Mathematics. Well, they just have the same concept as variables in programming. They act as a temporary storage for constant values like characters and numerics. These variables are declared, and as soon as you do that for your programs, a memory space will automatically be allocated and reserved for an expected value. While they’ll be destroyed whether manually or automatically, depending on the designation of the programming language, whenever they will no longer be of use. Note that these variables consume the random access memory to temporarily allow lots of application functionalities. So, as a programmer, you are solely responsible of how much or how less variables you need to create.
In a C / C++ Programming Language, the format to declare a variable is as follows:
variableType variableName;
variableType is the type of the variable to declare. Here is a list of common C / C++ variable or data types :
Data Type | Origin | Bits Allocated | Description |
int | Integer | 16 Bits | Stores numbers approximately from -2147483648 to +2147483648. |
char | Character | 8 Bits | Stores character with ASCII values from 0 to 255. |
float | Floating | 32 Bits | Stores up to 4 Bytes of floating numbers. |
double | Double Floating | 64 Bits | Stores up to double the size of float. |
bool | Boolean | 8 Bits | Stores values whether True or False. |
variableName is the name you will be defining for the variable. Which means, you decide what you call it. One good technique upon declaring variable names is through relating it with its purpose. In this way, you won’t easily forget the name of the variable. Also, as a rule for naming variables, you have to consider that: it should not start with a number; it should not contain any spaces and other special symbols such as #, $, %, * and more; it must not conflict with default C / C++ terms such as "if", "switch", "enum", and more.
Since variables are able to store values, depending on its nature, you can either assign a constant value for it or a value from another variable of the same data type. So, if the variable type is int, then you may only assign integer values for it.
To assign a constant value to a variable:
int num;
num = 15;
To assign a value from another variable:
int numVal;
numVal = num;
Remember that variables are very important in programming. It is always fully recommended to use variables most of the time. These help lessen confusion, prevent mistracking of values, and strengthen the construction of algorithms, which in the end improve the quality of programming.
Note: In the above C / C++ declarations, they all end in a character symbol ";". This tells the compiler that a statement has been ended or closed. So, if these won’t appear with each statement, it would most likely produce a compilation error. The compiler will always search for this symbol.

