Skip to main content
\(\newcommand{\doubler}[1]{2#1} \newcommand{\binary}{\texttt} \newcommand{\hex}{\texttt} \newcommand{\octal}{\texttt} \newcommand{\prog}{\texttt} \newcommand{\lt}{<} \newcommand{\gt}{>} \newcommand{\amp}{&} \)

Chapter4Basic Data Types

Each piece of data in a computer program has a data type, which specifies:

  • its possible values,

  • the way it is stored,

  • operations that can be performed on the data, and

  • its meaning.

Some programming languages require the programmer to explicitly state the data types of values used in the program. Examples are C, C++, and Java. Other languages, for example, Python, BASIC, can determine a data type from how the value is used. CPU architectures specify machine-level data types, often including specialized data types that are unique to that particular architecture.

In this chapter we study the relationship between the C/C++ integer (int) and character (char) data types. Composite data types are discussed in Chapter 15, and the float data type is discussed in Chapter 16.