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.
💡 Key insight
Use <code>sizeof(type)</code> in your code any time you need to check the real size on your system instead of guessing.
Syntax
syntax
int wholeNumber;
float singlePrecision;
double doublePrecision;
char singleCharacter;Example
sizeof() returns the size of a type in bytes on the current system.
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;
}outputint: 4 bytes
float: 4 bytes
double: 8 bytes
char: 1 bytes
Try it yourself
Copy this example into the C compiler and run it — try changing a value and see what happens.
