Can any body help me in this program. I feel function itself is 
wrong and how to make the program complete. PLEASE IT IS URGENT.

C++ program to convert an octal number to decimal and from decimal 
back to octal. 



#include <iostream>
#include <math.h>

using namespace std;

void octtodec();
void dectooct();

int main() { 
void octtodec(); 
void dectooct(); 
return 0;
}

void octtodec()
{
int oct,y,p,sum,x,m,i;

cout<<"Enter octal no : ";
cin>>oct;
for(i=1;m!=0;++i)
{
m=pow(10,i);
y=oct;
x=y%m;
p=x * pow(10,i-1);
sum +=p;
y/=10;
}

cout<<"the decimal value is "<<sum;
}


void dectooct()
{
int a[50],d,dec,count=0;

cout<<"Enter the decimal no";
cin>>dec;
for(int i=0;d!=0;++i)
{ 
d=dec;
a[i]=d%8;
d/=8;
count+=1;
}

cout<<"The octal no is";

for(i=count-1;i>=0;++i)
{ 
cout<<a[i];
}
}



Reply via email to