Skip to content

Instantly share code, notes, and snippets.

@Techgokul
Created December 2, 2017 06:39
Show Gist options
  • Save Techgokul/beccbd8e68b7c593ae0ae715c53b0f35 to your computer and use it in GitHub Desktop.
Save Techgokul/beccbd8e68b7c593ae0ae715c53b0f35 to your computer and use it in GitHub Desktop.
Convert Decimal to Binary using c
#include<stdio.h>
int main()
{
int n,c,k;
printf("Enter the integer in decimal number:\n");
scanf("%d",&n);
printf("%d is the binary number system is:\n",n);
for(c=31;c>=0;c--)
{
k=n>>c;
if(k & 1)
printf("1");
else
printf("0");
}
printf("\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment