Because the value represented by an octal literal is being printed out as decimal value on the standard output. If you want to output the octal literal value you should use the std::oct stream manipulator:
std::cout << std::oct << number;
Integer values are represented by integer literals. They can be octal such as 0437
, decimal such as 287
or hexadecimal such as 0x11f
and as of C++14 they can be binary literals such as 0b100011111
. All of these literals represent the same value.
4
solved Unsigned Number displays different results when a zero is appended to the number [duplicate]