In this tutorial, we will explain a simple program to convert the decimal number into binary number. We have not used any number validation in this program as it is designed for the beginners for learning purpose.

You can modify this program to validate the number entered by the user during the program execution, then user can only enter the decimal number as input.

Copy below c program and execute it with c complier to see the output of the program and also start converting the number system from decimal to binary number.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #include<stdio.h> #include<conio.h> #include<math.h> void dec_bin(long int num) { long int rem[50],i=0,length=0; while(num>0) { rem[i]=num%2; num=num/2; i++; length++; } printf("nBinary number : "); for(i=length-1;i>=0;i--) printf("%ld",rem[i]); } //================================================ void main() { long int num; clrscr(); printf("Please enter the decimal number: "); scanf("%ld",&num); dec_bin(num); getch(); } |

#First try

Please enter the decimal number: 80

Decimal number : 1010000

- C program to solve the Number of stopping station problem
- C implementation of inserting a new node to a link list
- C program to find the sum of all nodes in a tree
- C program to count number of non leaf nodes of a given tree
- C program to find the common ancestor and print the path
- C program to traverse the tree recursively
- C program to search for an element in the linked list without using recursion
- C Program to Implement Naor-Reingold Pseudo Random Function
- C Program to Implement the Bin Packing Algorithm
- How to Sort Linked List to Balanced BST

Article Tags: convert decimal numbers to binary, convert decimal to binary number, converting decimal numbers to binary, decimal to binary number converter, how to convert decimal numbers to binary, how to convert decimals to binary, how to convert to decimal to binary

We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok