Featured
- Get link
- X
- Other Apps
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:
#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++ |
- Get link
- X
- Other Apps
Labels:
C++ program to convert Decimal to Octal
decimal number to octal number conversion
decimal to octal conversion
decimal to octal conversion program in C++
Popular Posts
C++ program to display numbers which get reversed after multiplying by 4
- Get link
- X
- Other Apps
Comments
Post a Comment