Variables are simple, so are
if statements. Here's a quick overview of both of them:
Variables
A variable (Datum) is an instantiation of either a built-in type or user-defined type. All variables reserve a set amount of bytes (ranging from 1-n. Where n is the largest of user-defined and built-in types in bytes) within the computer’s memory. The type-specifier of a variable indicates the variable’s type. The type-specifier is used to determine the type of value that can be stored within the variable. It’s the type-specifier that gives the variable its size (without the type-specifier, how would we know the size of the datum?). For example, according to the C++ standard, a variable that is of type int should at least reserve 4 bytes of memory. The Symbol of a variable is an alias for the region of memory that is the variable. The symbol of the variable doesn’t contribute to the size of a variable. The memory address of the first byte of a datum is considered the address of the entire datum.
If Statement
The
if statement is a control structure. Each statement has a condition. If the condition evaluates to true, the statements within the following braces ({...}) are executed one by one. If the condition evaluates to false, the statements are ignored. Conditions always evaluate to either true or false, and nothing else.
if statements can be nested, which means an
if statement within the body of another
if statement. Following an
if statement are two related statements, called
else if and
else.
else if must be proceeded by an
if statement.
else if and
else are optional.
For further reading see these links:
if statements: http://www.cplusplus.com/doc/tutorial/control/
Variables: http://www.cplusplus.com/doc/tutorial/variables/
Wazzak