C++ decimal to octal

Here is an example C++ code to convert a decimal number into an octal number:

```cpp
#include <iostream>
using namespace std;

int main() {
int decimal, remainder, octal = 0, i = 1;
cout << "Enter a decimal number: ";
cin >> decimal;
while(decimal != 0) {
remainder = decimal % 8;
decimal /= 8;
octal += remainder * i;
i *= 10;
}
cout << "The octal equivalent is: " << octal << endl;
return 0;
}
```

In this code, we take input for a decimal number and store it in the `decimal` variable. We initialize `octal` to 0 and `i` to 1, which will be used to add digits to the octal number in the while loop.

We then loop through the decimal number until it is equal to 0. At each iteration, we find the remainder when dividing the decimal number by 8 using the modulus operator `%`. We then divide the decimal number by 8 and increment the `octal` variable by the remainder multiplied by `i`. We then multiply `i` by 10 to get the next digit's place for the octal number.

After the while loop, we output the octal equivalent of the decimal number.