#include<stdio.h>
main()
{
int n,rem,bin=0,k=1;
printf("Enter a decimal number ");
scanf("%d",&n);
while(n!=0)
{
rem=n%2;
bin=bin+rem*k;
k=k*10;
n=n/2;
}
printf("Binary = %d\n",bin);
}
No comments:
Post a Comment