Sign in
Log inSign up

Why is the following binary to octal conversion in 'c' not working?

Aritra Mukherjee's photo
Aritra Mukherjee
·Oct 14, 2016
//binary to octal conversion
#include<stdio.h>
#include<math.h>
int main()
{
    int binary,i=0,rem,c,count=0,x=0;
    printf("enter a binary number for conversion to decimal\n");
    scanf("%d",&binary);
    while(count<=3);
    {
    rem=binary%10;
    c=pow(2,i);
    x+=rem*c;
    i++;
    count++;
    }
    printf("the converted binary number to octal is:  %d",x);
    getch();
    return 0;
}