Skip to content

Instantly share code, notes, and snippets.

@sukso96100
Created October 19, 2016 02:38
Show Gist options
  • Save sukso96100/3f31577f3858691223e24f84b52e0816 to your computer and use it in GitHub Desktop.
Save sukso96100/3f31577f3858691223e24f84b52e0816 to your computer and use it in GitHub Desktop.
C Source that converts Decimal to Binary
#include<stdio.h>
int main(void){
int decimal, cal, i=0, j;
int bin[100];
printf("Type a Decimal\n");
scanf("%d", &decimal);
cal = decimal;
while(cal != 0){
bin[i] = cal % 2;
cal /= 2;
i++;
}
printf("Binary : ");
for(j = i-1; j > 0; j--){
printf("%d",bin[j]);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment