Octal

Program to convert octal number to a binary number...

int main()
{

int oct_dec,(int i)
int result = 0;
int n = 0;
int number = 0;

if (i < 10)
return i;


while (i / 10) {
number = i % 10;
result += (number * powl(8, n));
n++;
i /= 10;
}
result += (i * powl(8, n));
{
system("pause>0");
return result;
}

but it said undeclared identifier 'i' I already tried to bring out int oct_dec," (int i)" from the outside of the parenthesis but it is still not working.. Please help me to run this program correctly..
use code tags >.<

But change
 
int oct_dec,(int i)

to
 
int oct_dec, i;

Also what do you mean by this line?
 
while (i/10) {

It still dont run... i think that's a part of the formula to convert octal to binary??
if you include cmath and stdlib and add another curly bracket it should run
it says... warning C4244: '+=' : conversion from 'long double' to 'int', possible loss of data
I found this:

http://groups.engin.umd.umich.edu/CIS/course.des/cis400/cpp/binary.html


There was a fancier C++ version I saw somewhere, just trying to find it on Google

HTH

Here is a version using bitset.

http://www.java2s.com/Tutorial/Cpp/0360__bitset/writeadecimalintegerasabinarynumber.htm
Last edited on
Topic archived. No new replies allowed.