C Program to convert binary number into its equivalent Decimal, Octal, and Hexadecimal representations. In this program we convert a binary number to decimal. Then convert that decimal number to octal and Hexadecimal equivalent.
The program implements various functions to do the job.
- binary_to_decimal : Convert given binary number to it’s decimal equivalent
- decimal_to_octal : Convert from decimal to octal
- decimal_to_hex : Convert from decimal to hexadecimal
The main function takes care of getting input from user, calling the above functions and displaying the results.
Read more here: What are binary, octal, and hexadecimal notation?
The Program
[gist id = “d13c5fbfc46250b75871fb384db19e18”]
Sample Output

Related Programs
- C Program to convert Binary number to Decimal
- C program to find the 2’s complement of a binary number
- C Program to convert a given decimal number into its binary equivalent
You can discuss these programs on our Facebook Page. Like to get updates right inside your feed reader? Grab our feed!
Edit1 : 11th August 2017
- Added screenshot of sample runs
- Moved the code to it’s own Gist
- Modified the program to make it more modular
(c) www.c-program-example.com
3 comments on “C program to convert a Binary number into its equivalent Decimal, Octal and Hexadecimal numbers.”
C program to convert a binary number to decimal,octal and hexadecimal number and back
what about fractional number…do you have any idea?…please share.