Computer Science, asked by deeplalkumar1400036, 1 year ago

binary to octal c programming

Answers

Answered by garywalter1221
0

#include <stdio.h>

 

int main()

{

   long int binarynum, octalnum = 0, j = 1, remainder;

 

   printf("Enter the value for  binary number: ");

   scanf("%ld", &binarynum);

   while (binarynum != 0)

   {

       remainder = binarynum % 10;

       octalnum = octalnum + remainder * j;

       j = j * 2;

       binarynum = binarynum / 10;

   }

   printf("Equivalent octal value: %lo", octalnum);

   return 0;

}

hope it will help u


Similar questions