All values are stored using binary representation (this is true for integers, floats, characters, etc). The value 10 (decimal) is stored as the sequence of binary digits 00000000000000000000000000001010 (assuming a 32-bit int type).
In an assignment statement like
i = 012;
the compiler knows how to convert the string of octal digits in the literal 012 into the binary representation above. The leading 0 tells the compiler that the value is in octal representation, otherwise it would try to store the decimal value 12 (00000000000000000000000000001100).
In the printf statement
printf("%d\n", i);
the conversion specifier %d tells printf to display the value stored in i formatted as a string of decimal digits (10). Similarly, the conversion specifier %x will display the value formatted as a string of hex digits (a).