Professional Documents
Culture Documents
system. How to convert from binary number system to octal number system in C.
Example:
Input binary number: (00110111)2
Output octal number: (67)8
Required knowledge:
Basic C programming, For loop
Program:
/**
* C program to convert binary to octal number system
*/
#include <stdio.h>
int main()
{
int octalConstant[] = {0, 1, 10, 11, 100, 101, 110, 111};
octal = 0;
count = 1;
/*
* Reads binary number from user
*/
printf("Enter any binary number: ");
scanf("%lld", &binary);
/*
* Finds the octal equivalent of binary value
*/
while(tempBinary != 0)
{
digit = tempBinary % 1000;
tempBinary /= 1000;
count *= 10;
}
return 0;
}