This program will ask the user for a decimal number and convert the number into octal.
#include <iostream>
#include <cstdlib>
using namespace std;
int main(int argc, char const *argv[])
{
int n;
int _dec;
int _oct = 0;
int dp = 1;
cout<<"Enter a number: ";
cin>>n;
_dec = n;
do {
_oct += (_dec % 8) * dp;
_dec /= 8;
dp *= 10;
} while( _dec != 0 );
cout << "The octal of " << n;
cout << " is " << _oct;
cin.get();
return 0;
}