Write a program to convert decimal number in to binary number.

 Code:-

#include<stdio.h>

int main()
{
int n,r,i=0,j;
char bin[100],x;
printf(“Enter a numbern”);
scanf(“%d”,&n);
while(n!=0)
{
r=n%2;
x=r;
bin[i]=x;
i++;
n=n/2;
}
printf(“Binary of the number is: “);
for(j=i1;j>=0;j–)
printf(“%d”,bin[j]);
return 0;
}

Output:-

Enter a number
10
Binary of the number is: 1010



Leave a Reply

Your email address will not be published.