Write a C program to convert decimal no. to binary.

Added 2 years ago
Active
Viewed 1057
Ans

 

#include<stdio.h>
#include<conio.h>
main()
{
	int bin[50],i=0,n,j;
	printf("\n Enter any decimal number");
	scanf("%d",&n);
	while(n>0)
	{
		bin[i]=n%2;
		n=n/2;
		i++;
	}
	for(j=i-1;j>=0;j--)
	{
		printf(" %d ",bin[j]);
	}
	getch();
}

 

Output:



Related Questions