Skip to main content

Featured

functions in Python

C++ program to convert Decimal to Octal

/*Following program converts a decimal number to its octal equivalent*/
#include<iostream.h>
#include<conio.h>
void dec2octal(long num)
{
int rem,i=0,arr[15];
while(num>8)
{
rem=num%8;
arr[i++]=rem;
num=num/8;
}
arr[i]=num;
cout<<"Octal Equivalent is<< ";
for(;i>=0;i--)
cout<<arr[i];
}
void main()
{
clrscr();
long n;
cout<<"\nEnter A Decimal Number\n";
cin>>n;
dec2octal(n);
getch();
}

OUTPUT:
DECIMAL TO OCTAL CONVERSION PROGRAM IN C++

Comments

Popular Posts