Every expression has a type – a formal description of what kind of data its value is. For instance, 0 is an integer, 3.142 is a ﬂoating-point (decimal) number, and "Hello, world!\n" is a string value (a sequence of characters).
Data of different types take a different amounts of memory to store. Here are the built-in datatypes we will use most often:
|char||Single text character or small integer.Indicated with single quotes (’a’, ’3’).||1 byte||signed: -128 to 127 unsigned: 0 to 255|
|int||Larger integer.||4 bytes||signed: -2147483648 to 2147483647 unsigned: 0 to 4294967295|
|bool||Boolean (true/false). Indicated with the keywords true and false.||1 byte||Just true (1) or false (0).|
|double||“Doubly” precise ﬂoating point number.||8 bytes||+/- 1.7e +/- 308 ( 15 digits)|
Notes on this table:
An operator also normally produces a value of the same type as its operands; thus, 1 / 4 evaluates to 0 because with two integer operands, / truncates the result to an integer. To get 0.25, you’d need to write something like 1 / 4.0. A text string, has the type char *.