C Data Types

Beginner
6 min read
Updated: Nov 2026
1 example

What Is Data Types?

A data type tells the compiler how much memory a value uses and how to interpret its bits. The basic types are char, int, float, double, and the modifiers short, long, signed, and unsigned. Sizes depend on the platform; use sizeof to check them.

Remember
char   c = 'A';       /* 1 byte */
int    i = 42;        /* usually 4 bytes */
float  f = 3.5f;      /* usually 4 bytes */
double d = 3.14159;   /* usually 8 bytes */
unsigned int u = 7u;  /* no negative values */

Cheat Sheet

Keep these facts handy while you work with Data Types in C.

TopicDetail
charSmall integer, usually a character, 1 byte
intNatural integer size, at least 16 bits (usually 32)
float / doubleSingle / double precision floating point
Check sizesizeof(type) returns a size_t

C Examples

Compile each example with gcc file.c -std=c11 -Wall -o out. Next: Type Conversion.

Example 1 — Sizes of the basic types

Print sizeof for each type on a typical 64-bit system.

C
#include <stdio.h>

int main(void) {
    printf("char:   %zu\n", sizeof(char));
    printf("int:    %zu\n", sizeof(int));
    printf("float:  %zu\n", sizeof(float));
    printf("double: %zu\n", sizeof(double));
    return 0;
}

How It Works

  1. sizeof yields the size in bytes as a size_t.
  2. %zu is the correct specifier for size_t.
  3. Sizes shown are typical for GCC on 64-bit Linux, macOS, and Windows; the standard only sets minimums.

Edge Cases & Pitfalls

Check these before relying on Data Types in real programs.

range

Integer overflow

Signed overflow is undefined behavior. Use a wider type or check before adding.

float

Float precision

0.1 + 0.2 is not exactly 0.3 in binary floating point. Compare with a tolerance.

Key Takeaways

  • Choose: pick the type that fits the data.
  • Verify: use sizeof, do not assume.
  • Careful: floats are approximate.

One line: A data type tells the compiler how much memory a value uses and how to interpret its bits.

Frequently Asked Questions

The standard guarantees at least 16 bits, but on common desktop and server platforms int is 32 bits (4 bytes).
Use double by default; it has about 15 digits of precision. Use float only for memory-sensitive arrays or when an API requires it.
Continue with "C Type Conversion" next. Implicit promotion and explicit casts between types. The C Fundamentals hub lists every topic in order.

Next: Type Conversion

Implicit promotion and explicit casts between types.

Continue →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful