1.6.1 Data Types

Programs use variables to refer to storage elements in the memory of the high-level computer. Each variable has a name, which refers to its storage elements, and a value, which is the content of those elements. For example, the C assignment statement

sum = sum + increment;

uses two variables with names sum and increment. Individual variables, which correspond to a single storage element, are the simplest type of data structure. More complex structures are built from variables. In turn, operations on the more complex structures are built from operations on the simpler structures. High-level languages differ in the kinds of basic data structures they provide. For example, FORTRAN includes individual variables and dimensioned arrays. C adds records and pointers and, significantly, allows the definition of new data types and data structures. The Ada language allows new basic operations to be introduced as well.

Each variable must be defined by a declaration that gives its name and data type. The data type indicates the actual values that may by assumed by the variable. For example, the C declaration

int sum, increment;

char check;

specifies that sum and increment are the names of variables whose values will be integers, and that check is the name of a variable whose values will be a character.