Skip to content

Instantly share code, notes, and snippets.

@mkrat123
Last active October 29, 2017 04:37
Show Gist options
  • Save mkrat123/c04c7e4b5adc881196dc2d66a3dcedc2 to your computer and use it in GitHub Desktop.
Save mkrat123/c04c7e4b5adc881196dc2d66a3dcedc2 to your computer and use it in GitHub Desktop.
//decimal to binary
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
int main(int argc,char *argv[]){
int n=atoi(argv[1]);
int binaryNum[1000];
int i = 0;
while (n > 0) {
binaryNum[i] = n % 2;
n = n / 2;
i++;
}
for (int j = i - 1; j >= 0; j--)
printf("%d",binaryNum[j]);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment