C Program to Convert Decimal Number into Binary
In this program we will convert decimal number into binary number.
- // C program to convert decimal to binary
- #include <stdio.h>
- #include <math.h>
-
- long decimalToBinary(int decinum)
- {
- long binum = 0;
- int rem, temp = 1;
-
- while (decinum!=0)
- {
- rem = decinum%2;
- decinum = decinum / 2;
- binum = binum + rem*temp;
- temp = temp * 10;
- }
- return binum;
- }
-
- int main()
- {
- int decinum;
- printf("Enter a Decimal Number: ");
- scanf("%d", &decinum);
- printf(" Binary Number is: %ld", decimalToBinary(decinum));
- return 0;
- }
Output

Solution not working or have any suggestions? Please send an email to [email protected]
Download Android App