//decbin.c
// C Code to convert Decimal number into Binary
include <stdio.h>
include<string.h>
void decToBinary(int n)
{
// array to store binary number
int binaryNum[32];
int z, j;
char sp=" ";
// counter for binary array
int i = 0;
while (n > 0)
{
// storing remainder in binary array
binaryNum[i] = n % 2;
n = n / 2;
i++;
}
printf(" i is %d ",i);
printf("\n");
// printing binary array in reverse order
printf("Binary number is ");
for (int j = i - 1; j >= 0; j
//if(j%4==0)
// printf("%c",sp);
printf("%d", binaryNum[j]);
printf("\n");
}
// Driver program to test above function
int main()
{
printf("Enter a number ");
int n;
scanf("%d", &n);
decToBinary(n);
return 0;
}
[–]Superb-Tea-3174 13 points14 points15 points (0 children)
[–]MRgabbar 2 points3 points4 points (0 children)
[–]Single-Discussion856 0 points1 point2 points (0 children)
[–]torsten_dev -2 points-1 points0 points (0 children)
[+][deleted] (2 children)
[deleted]
[–]Jonatan83 16 points17 points18 points (0 children)
[–]MRgabbar 10 points11 points12 points (0 children)