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));
i /= 10;
result += (i * powl(8, n));
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)

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:


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


Here is a version using bitset.

Last edited on
Topic archived. No new replies allowed.