Please have a look at the following article for an overview of Binary, Octal, Decimal & Hex values.

What are Binary, Decimal, Octal & Hexadecimal values?
In this article, I explain Binary, decimal and octal numbers with examples. Binary values are also known as Base 2 values.

Decimal to binary

int data_holder = 33;

As shown in the above statement, when we assign a decimal value to a variable, first the value is converted to binary from decimal value and later it will be stored in computer memory space. Let's see how to do that.

Consider the decimal value is 33. Now to get the binary value from this decimal value divide this value with '2' repeatedly until you get '1'.

100001After dividing it, note down the remainder from bottom to top. Then the binary value looks like

At each step, note down the remainder that you are getting. For more info see the below picture.

Decimal to Octal:

Steps to follow:

  1. Decimal to binary (Refer above section)
  2. Binary to octal (Refer to this article)

Example:

Decimal: 33
Binary: 100001
Octal: 41

Decimal to Hex:

Steps to follow:

  1. Decimal to binary (Refer above section)
  2. Binary to Hexa (Refer to this article)

Example:

Decimal: 33
Binary: 100001
Hexa: 21