There are several simple types of data commonly used in C and C++ programs:
|Name||Data||Typical Size (bytes)1)|
|double||Floating-point number with twice the precision of a float||8|
|void||No type (useful for defining functions with no return value).||N/A|
A variable is a location in memory used to store data. Variables are assigned names and data types by the programmer at the beginning of the program or function. Examples:
int iter=0; // An integer variable initially assigned a value of zero double energy; // A double-precision floating-point number int z_values; // An array of integers double geom; // A two-dimensional array (a matrix) of doubles
Note: You should never assume that the value of a variable has been “initialized” (set to zero) by the compiler. More often, the memory location specified by a variable contains (seemingly) random bits until you assign a value to it.