/* Decimal to Binary. */
#include <stdio.h>
int main()
{
int a[10], n, i = 0, temp;
printf("Enter a decimal number you want to convert: ");
scanf("%d", &n);
temp = n;
while(n > 0){
a[i] = n%2;
n = n/2;
i++;
}
printf("Binary of %d is = ", temp);
for(i = i-1; i >= 0; i--)
printf("%d", a[i]);
return 0;
}
Comments
Post a Comment