Sunday, November 18, 2012

Convert decimal numbers to octal numbers in C++

#include<iostream.h>
#include<conio.h>
int main ()
{
    int num,i=0;
    cout<<"Enter the decimal number:";
    cin>> num;
    while(num>0)
    {
                i=num%8;
                num=num/8;  cout<<i;
                }
                cout<<"(Result in reverse order)";
                getch ();
                return 0;
}

No comments:

Post a Comment