C program to Convert Decimal To Binary - Convert Decimal To Binary in C
![c program to convert decimal to binary](https://wikitechy.com/cdn/tutorials/c-programming/c-program-to-convertc-decimal-to-binary.gif)
Learn C - C tutorial - c program to convert decimal to binary - C examples - C programs
C program to Convert Decimal To Binary
Decimal number
- A decimal number consists of a dot called decimal point.
- The decimal point separates the whole number part and the fractional part in a decimal number.
- The value of a digit according to the place of the digit in a number is known as the place value of that digit.
![Decimal Number](https://wikitechy.com/cdn/tutorials/c-programming/decimal-number.png)
Learn C - C tutorial - Decimal Number - C examples - C programs
Binary number
- A number which uses only two symbols: 0 (zero) and 1 (one),is said to be the binary numbers.
- Any combination of 0 and 1 is binary number such as 1001, 101, 11111, 101010 etc.
Sample Code
#include<stdio.h>
int main()
{
long int decimalNumber=4.8, quotient;
int binaryNumber[100],i=1,j;
printf("Decimal number:4.8\n ");
quotient = decimalNumber;
while(quotient!=0)
{
binaryNumber[i++]= quotient % 2;
quotient = quotient / 2;
}
printf("Binary conversion of %d :\n ",decimalNumber);
for(j=i-1; j>0; j--)
printf("%d",binaryNumber[j]);
return 0;
}
Output
Decimal number:4.8
Binary conversion of 4 :
100