Data Types in C

A data type tells C what kind of value a variable will store. It also affects the operations that can be performed and the amount of memory used.

Basic data types

TypeStoresExampleTypical use
charone characterchar grade=’A’;letters/symbols
intwhole numberint age=20;count, age, marks
floatdecimal valuefloat price=25.5f;decimal values
doublemore precision decimaldouble pi=3.14159;scientific/precise values
voidno valuevoid display(void);functions with no return value

Derived and user-defined types

  • Array – stores multiple values of the same type.
  • Pointer – stores an address in memory.
  • Structure (struct) – groups related values of different types.
  • Union – different members share the same memory area.
  • Enumeration (enum) – creates named integer constants.

sizeof operator

#include <stdio.h>

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

 

The exact size of some types can depend on the compiler and platform, so sizeof is the correct way to check the size on your system.

📝 EXAM POINT: Do not assume every C data type has exactly the same size on every computer.
Scroll to Top