---
title: 1.3 Basic C Data Types
description: "C provides several fundamental data types for representing characters, integers, and floating-point values. The size and range of a type can vary between implementations, so `sizeof` is used here to show the storage size of each type on the system…"
url: "https://edcret.in/docs/c-programming/basic-refreshers/1-3-basic-c-data-types/"
updated: "2026-09-06"
category: C Programming / Basic Refreshers
---

# 1.3 Basic C Data Types

C provides several fundamental data types for representing characters, integers, and floating-point values. The size and range of a type can vary between implementations, so `sizeof` is used here to show the storage size of each type on the system running the program.

```
#include <stdio.h>

int main()
{
    char ch = 'A';
    short s = 100;
    int i = 1000;
    long l = 100000L;
    long long ll = 1000000000LL;
    float f = 3.14f;
    double d = 3.141592;
    long double ld = 3.141592L;
    _Bool flag = 1;

    printf("char        : %zu byten", sizeof(ch));
    printf("short       : %zu bytesn", sizeof(s));
    printf("int         : %zu bytesn", sizeof(i));
    printf("long        : %zu bytesn", sizeof(l));
    printf("long long   : %zu bytesn", sizeof(ll));
    printf("float       : %zu bytesn", sizeof(f));
    printf("double      : %zu bytesn", sizeof(d));
    printf("long double : %zu bytesn", sizeof(ld));
    printf("_Bool       : %zu byten", sizeof(flag));

    return 0;
}
```

### Example Output

The exact sizes are implementation-dependent. A common result is:

```
char        : 1 byte
short       : 2 bytes
int         : 4 bytes
long        : 8 bytes
long long   : 8 bytes
float       : 4 bytes
double      : 8 bytes
long double : 16 bytes
_Bool       : 1 byte
```

### Explanation

The fundamental data types used in the example are:

| Type | Purpose |
| --- | --- |
| `char` | Character and small integer values |
| `short` | Small signed integer values |
| `int` | Integer values |
| `long` | Larger integer values |
| `long long` | Large integer values |
| `float` | Single-precision floating-point values |
| `double` | Double-precision floating-point values |
| `long double` | Extended-precision floating-point values |
| `_Bool` | Boolean values, `0` or `1` |

The integer types can be modified with `signed`, `unsigned`, `short`, and `long`. The exact ranges depend on the implementation.

The suffixes used in the initializers specify the intended literal type:

```
100000L
1000000000LL
3.14f
3.141592L
```

`sizeof` returns the size of an object in bytes and has type `size_t`, which is why `%zu` is used with `printf()`.

### Minimum Size Requirements

C specifies minimum ranges and relative size requirements rather than requiring the same size on every platform.

| Type | Minimum size requirement |
| --- | --- |
| `char` | 1 byte |
| `short` | 2 bytes |
| `int` | 2 bytes |
| `long` | 4 bytes |
| `long long` | 8 bytes |
| `float` | Implementation-defined |
| `double` | Implementation-defined |
| `long double` | Implementation-defined |

A byte in C is the size of a `char`, and `sizeof(char)` is always `1`. The number of bits in a byte is implementation-defined and can be obtained from `CHAR_BIT` in `<limits.h>`.
