Notes / C / Data Types

Data Types in C — Revision Notes

A quick-reference cheat sheet: definition, syntax, example, common mistakes and an interview tip.

beginner 📖 2 min revision

Definition

📌 Data Types C has a small set of built-in (primitive) data types that describe what kind of value a variable can hold, and how much memory it uses.The exact size of a type can vary slightly by system, but the common sizes on most modern platforms are shown below..

Syntax

syntax
int wholeNumber;
float singlePrecision;
double doublePrecision;
char singleCharacter;

Example

c
#include <stdio.h>

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

Output

outputint: 4 bytes float: 4 bytes double: 8 bytes char: 1 bytes

Important Points

Common Mistakes

Interview Tip

🎯 Before your interview A classic interview question: "why prefer double over float?" — double has roughly twice the precision, at the cost of more memory.
Back to notes Read full lesson →