C Program - Binary to Octal



#include <stdio.h>
#include <conio.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);
getch();

    return 0;
}


Output
---------


Comments

Popular posts from this blog

Introduction to C++ Programming Language

The Assembly Process Of 8086 Microprocessor-Two Pass Assembling Steps

Installing 8086 Assembler on a Computer