C Program To Implement To Conversion From Decimal to binary Code:Convert decimal to binary c code. This c program, simply converts the decimal number in ‘1’ or ‘0’ form i.e binary number by dividing the decimal number by 2 and storing its remainder in an array, and reprinting the array variable in reverse order. You can also see for the c program to convert binary to decimal number.
ALGORITHM:-
step 1 : Start
step 2 : Enter any decimal number to find out the binary value
step 3 : Define an array
step 4 : Decimal%2 of decimal and store module in an array utill zero
step 5 : Display the array value in reverse order
step 6 : Stop Execution
PROGRAM CODE:-
#include<stdio.h>
#include<conio.h>
void main()
{
int a[20];
int dec,i=0;
printf("Enter decimal to calculate binary number\n");
scanf("%d",&dec);
while(dec>0)
{
a[i]=dec%2;
i++;
dec=dec/2;
}
printf("Binary number of %d is = ",dec);
for(int j=i-1;j>=0;j--)
{
printf("%d",a[j]);
}
getch();
}
OUTPUT:-
Enter Decimal to calc binary number: 10
Binary nummber of 16 is = 1010
C Program To Convert Decimal to binary number How to Convert an Decimal number into Binary Number Decimal To Binary Conversion
ConversionConversion EmoticonEmoticon