This program converts binary to octal
#include <stdio.h>
#include <math.h>
int main (){
int num, i, j;
printf("Enter number: ");
scanf("%d", &num);
int temp1 = 0;
int temp2 = 0;
int oct = 0;
int nw;
for (i = 0; num != 0; i++){
nw = num%1000;
printf("\ni: %d \nnw: %d\n", i, nw);
for (j = 0; nw != 0; j++){
if (nw%10==1){
temp1 += (po1w(2, j));
nw/=10;
}
}
temp2 = temp1 * pow(10,i);
printf("\nOct for now: %d\n", temp2);
oct += temp2;
temp1 = 0;
temp2 = 0;
num/=1000;
}
printf("\nThe Octal is %d", oct);
};
But whenever it is ran, it doesn't except when the inputted numbers are just few binary numbers and without zero, but whenever it has zero in the binary it doesn't run at all