//Decimal to Octal
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
long n,dn,r,base=1,oct=0;
cout<<"Enter any decimal value\n";
cin>>n;
dn=n;
while(n>0)
{
r=n%8;
oct=oct+r*base;
n=n/8;
base=base*10;
}
cout<<"Enter Number is:"<<dn<<endl;
cout<<"Octal value is:"<<oct<<endl;
getch();
}
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
long n,dn,r,base=1,oct=0;
cout<<"Enter any decimal value\n";
cin>>n;
dn=n;
while(n>0)
{
r=n%8;
oct=oct+r*base;
n=n/8;
base=base*10;
}
cout<<"Enter Number is:"<<dn<<endl;
cout<<"Octal value is:"<<oct<<endl;
getch();
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.