Converting decimal to octal This is a simple program converting user input decimal numbers into octal ones. 

#include &lt;iostream&gt;
using namespace std;
main()
{
    int de,oc,y,i=1,octal;
    float decimal,deci,x;
    cout&lt;&lt;"Enter decimal no :: ";
    cin&gt;&gt;decimal;
    de=decimal;
    deci=decimal-de;
    cout&lt;&lt;"("&lt;&lt;decimal&lt;&lt;")10 = (";
    while(de&gt;0)
    {
        oc=de%8;
        de=de/8;
        octal=octal+(oc*i);
        i=i*10;
    }cout&lt;&lt;octal&lt;&lt;".";
    while(deci&gt;0)
    {
        x=deci*8;
        y=x;
        deci=x-y;
        cout&lt;&lt;y;
    }
    cout&lt;&lt;")8";
}
Just, i don't understand why?

What's wrong with (for integer):

#include &lt;iostream&gt;
int main() {
    int input;
    std::cout &lt;&lt; "Enter decimal number: ";
    std::cin &gt;&gt; std::dec &gt;&gt; input;
    std::cout &lt;&lt; '\n' &lt;&lt; std::oct &lt;&lt; input &lt;&lt; '\n';
}


And about your code:


Avoid using namespace std, it's a bad practice
Just main() isn't a valid prototype for the entry point, at least use `int main()
Define variables in the closest scope possible.
Try naming variable consistently
de=de/8; can be simplified to de /= 8;
floating point conversion is a bit more tricky than just doing what you do


Edit: After testing it (and correcting main() and) : Your code just doesn't work, even for an integer value

Enter decimal no :: (0)10 = (32767.)8
Enter decimal no :: (8)10 = (32776.)8
Enter decimal no :: (10)10 = (32779.)8


Test yourself