Data Types


In the C programming language, data types are used to define the type of data that a variable can hold. Each data type determines the size of the variable and the range of values it can store.

Types Of Data Types In C Programming:

  1. Integer Types:
      • int: Represents integers, typically with a size of 4 bytes.
      • short: Represents small integers, typically with a size of 2 bytes.
      • long: Represents long integers, typically with a size of 4 or 8 bytes.
      • long long: Represents very long integers, typically with a size of 8 bytes.
  2. Floating-Point Types:
      • float: Represents single-precision floating-point numbers.
      • double: Represents double-precision floating-point numbers.
      • long double: Represents extended-precision floating-point numbers.
  3. Character Types:
    • char: The char data type, on the other hand, represents a single character and typically occupies 1 byte of memory.
  4. Boolean Type:
    • _Bool: Represents boolean values (0 for false, non-zero for true). Introduced in C99. Can also be used with the bool keyword in C++.
  5. Void Type:
    • void: Represents the absence of a type. It is commonly used to indicate that a function does not return a value or that a pointer does not specify a specific type.
  6. Derived Types:
    • Arrays: A collection of elements of the same type.
    • Pointers: Variables that store memory addresses.
    • Structures: User-defined data types that group together related variables under one name.
    • Enums: User-defined data types that consist of a set of named values.

It’s important to note that in C, a statically typed language, you must declare variables with their respective data types before using them. Furthermore, you can use modifiers with these basic data types to specify additional properties such as signed/unsigned or short/long.

Additionally, for quick reference, presented below is a table that contains commonly used types in C programming.

Data types with Size and the associated format specifier

This table provides a breakdown of the data types, their corresponding size in bytes, and the associated format specifier in the following manner:

TypeSize (bytes)Format Specifier
int4%d
short int2%hd
long int4 or 8%ld or %lld
long long int8%lld
unsigned int4%u
unsigned long int4 or 8%lu or %llu
unsigned long long int8%llu
signed char1%c
unsigned char1%c or %u
float4%f
double8%lf
long double12 or 16%Lf or %Le


Additionally, the following table serves as a quick reference for commonly used data types in C programming, encompassing their corresponding sizes in bytes and format specifiers for printing values of those types using the printf function. Please note that the size of data types can vary depending on the compiler and platform.

Understanding and utilizing the appropriate data types in C programming is essential for efficient memory usage, accurate calculations, and proper manipulation of data. Moreover, choosing the right data type based on the nature and range of values you expect to work with ensures the correctness and efficiency of your programs.

By selecting the appropriate data type, you can effectively manage memory resources and ensure precise calculations. In doing so, you can optimize memory usage and accurately perform calculations.

Additionally, it enables seamless manipulation of data by providing the necessary level of granularity. Therefore, considering the characteristics and requirements of your data, it becomes crucial to select the appropriate data type to achieve optimal program performance.