Subscribe for more such posts..

Dear Reader...
I hope u are like my posts. If so then please don't forget to like , share and follow my blog for more such posts ,also feel free to write suggestions in the comment box given over here.

Thank you...

Search This Blog

C program to convert a Decimal number to Binary number.


 #include <stdio.h>
int main()
{
	 int n , rem  , i = 1 , bn = 0 ;
	printf("Enter a positive decimal number : ");
	scanf("%d" , &n);
	
	printf("The binary number of decimal %d is : " , n);
	
	while (n > 0)
	
	{
		rem = n % 2 ;
     	bn +=  (i * rem);
		i = i * 10 ;
		n = n / 2;
		
	}
	
	 printf("%d\n",bn);
	
	return 0 ;
}



No comments:

Post a Comment