Variables
Variable Type | Description |
Size in Bytes |
Range from |
Range to |
char | Character |
1 |
-128 |
127 |
unsigned char | Unsigned Character |
1 |
0 |
255 |
short | Short Integer |
2 |
-32, 768 |
32,767 |
unsigned short | Unsigned Short Integer |
2 |
0 |
65,535 |
int long |
Integer Long Integer |
4 |
-2,147,483,648 |
2,147,483,647 |
unsigned int unsigned long |
Unsigned Integer Unsigned Long Integer |
4 |
0 |
4,294,967,296 |
float | Floating Point (Real) |
4 |
-3.4E308 -3.4 x 10^308 |
3.4E38 -3.4 x 10^308 |
double | Double Floating Point (Real) |
8 |
-1.7E308 -1.7 x 10^308 |
1.8E308 1.8 x 10^308 |
bool | Boolean (true or false) |
1 |
false |
true |
Upper and Lower-Case Variable Names
By convention, if you declare and define a variable, you should give it a name beginning with a lower-case letter.
Variable Arrays
A variable may hold
a single value like: myAge
A one-dimensional list of the ages of 25 students in this class: studentAge[25] with indices ranging from 0 to 24.
A two-dimensional table of the position of pieces on a chess board: chessGame[8][8] with indices ranging from 0 to 7.
Indices are always set off by square brackets [] and we always begin counting index values at zero.
Variable Scope