Skip to main content
Engineering LibreTexts

3.1: Data Types in C

  • Page ID
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)

    ( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\id}{\mathrm{id}}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\kernel}{\mathrm{null}\,}\)

    \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\)

    \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\)

    \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    \( \newcommand{\vectorA}[1]{\vec{#1}}      % arrow\)

    \( \newcommand{\vectorAt}[1]{\vec{\text{#1}}}      % arrow\)

    \( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vectorC}[1]{\textbf{#1}} \)

    \( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)

    \( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)

    \( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)

    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    General Discussion

    Our interactions (inputs and outputs) of a program are treated in many languages as a stream of bytes. These bytes represent data that can be interpreted as representing values that we understand. Additionally, within a program we process this data in various ways such as adding them up or sorting them. This data comes in different forms. Examples include: yourname which is a string of characters; your age which is usually an integer; or the amount of money in your pocket which is usually a value measured in dollars and cents (something with a fractional part). A major part of understanding how to design and code programs in centered in understanding the types of data that we want to manipulate and how to manipulate that data.

    type defines a set of values and a set of operations that can be applied on those values. The set of values for each type is known as the domain for that type."1 The four major families of data include:

    • Nothing
    • Integer
    • Floating-point
    • Complex

    The C++ programming language identifies five data types as standard data types:

    • Void
    • Boolean
    • Character
    • Integer
    • Floating-point

    The standard data types and the complex data types within C++ have a series of attributes, which include:

    • C++ Reserved or Key Word
    • Domain – the allowed values
    • Signage – do they allow negative numbers or only positive numbers
    • Meaning – i.e. What do they represent
    • Rules of Definition – What special characters indicate the data type
    • Size – in terms of the number of bytes of storage used in the memory
    • Operations Allowed – i.e. Which operators can I use on the data type

    Placing some of the above into a summary table, we get:

    Family Data Type Reserved Word Represents Standard Type
    Nothing Null or nothing void No data Yes
    Integer Boolean bool Logical true and false Yes
    Integer Character char single characters Yes
    Integer Integer int Whole numbers Yes
    Floating Point Floating Point float Fractional numbers Yes
    Complex String string A sequence (sting them along) of characters No
    Complex Array N/A A collection of elements of the same data type No
    Complex Pointer N/A A value that points to a location (an address) within the data area No

    The five standard data types usually exist in most programming languages and act or behave similarly from language to language. Most courses of study for a programming course or language will explain the standard data types first. After they are learned, the complex data types are introduced.

    The Boolean, character and integer data types are identified as belonging to the Integer Family. These data types are all represented by integer numbers and thus act or behave similarly.


    1 Behrouz A. Forouzan and Richard F. Gilberg, Computer Science A Structured Approach using C++ Second Edition (United States of America: Thompson – Brooks/Cole, 2004) 33.


    Data Type
    Defines a set of values and a set of operations that can be applied on those values.
    Data Type Families
    1) Nothing 2) Integer 3) Floating-Point 4) Complex
    The set of allowed values for a data type.
    A data type representing whole numbers
    Floating Point   
    A data type representing numbers with fractional parts.

    This page titled 3.1: Data Types in C is shared under a CC BY license and was authored, remixed, and/or curated by Kenneth Leroy Busbee (OpenStax CNX) .

    • Was this article helpful?