Primitive Types

What type of things we can put inside a box

Primitive Types

Some basic things that we would put in a box

Variables are containers for values. We use different typed variables to store different typed values, e.g. integer, decimal, text.

These are the primitive types in C, the most basic variable types:

TypeDescriptionExample Literal

char

8-bit integer* for storing an ASCII character

'a'

int

16-bit/32-bit signed integer**

1

float

32-bit, single-precision floating point value (i.e. dotted number)

3.012f

double

64-bit, double-precision floating point value (i.e. a longer dotted number)

5.012345

void

the absence of type (i.e. no type)

/

  • *Whether char is signed or unsigned is machine-dependent.

  • **Size is compiler-dependent and machine-dependent.

Variable Declaration

int some_integer; // Declaring some_integer as a integer
char c; //Declaring c as a character
float f; //Declaring f as a 32-bit, single-precision floating point value

Last updated