xtreme1131
2009-09-20 20:06:29 UTC
heres my code:
#include
using namespace std;
int main()
{
int d[10];
long x[9];
unsigned long n;
int a[8];
long b[7];
char A;
char B;
char C;
char D;
char E;
char F;
//Decimal to Octal
cout<<"Enter a decimal number"<
d[0]=n%8;
x[0]=n/8;
d[1]=x[0]%8;
x[1]=x[0]/8;
d[2]=x[1]%8;
x[2]=x[1]/8;
d[3]=x[2]%8;
x[3]=x[2]/8;
d[4]=x[3]%8;
x[4]=x[3]/8;
d[5]=x[4]%8;
x[5]=x[4]/8;
d[6]=x[5]%8;
x[6]=x[5]/8;
d[7]=x[6]%8;
x[7]=x[6]/8;
d[8]=x[7]%8;
x[8]=x[7]/8;
d[9]=x[8]%8;
x[9]=x[8]/8;
d[10]=x[9]%8;
//Decimal to Hex
a[0]=n%16;
b[0]=n/16;
a[1]=b[0]%16;
b[1]=b[0]/16;
a[2]=b[1]%16;
b[2]=b[1]/16;
a[3]=b[2]%16;
b[3]=b[2]/16;
a[4]=b[3]%16;
b[4]=b[3]/16;
a[5]=b[4]%16;
b[5]=b[4]/16;
a[6]=b[5]%16;
b[6]=b[5]/16;
a[7]=b[6]%16;
b[7]=b[6]/16;
a[8]=b[7]%16;
for (int i=0;i<9;i++)
if (a[i]<=9) {
a[i]= a[i];}
else if (a[i]==10) {
a[i]=A;}
else if (a[i]==11){
a[i]=B;}
else if (a[i]==12) {
a[i]=C;}
else if (a[i]==13){
a[i]=D;}
else if (a[i]==14){
a[i]=E;}
else if (a[i]==15){
a[i]=F;}
cout<<"Octal equivalent: "<
cout<<"Hexidecimal equivalent: "<system("pause");
return 0;
}