Last active
October 29, 2017 04:37
-
-
Save mkrat123/c04c7e4b5adc881196dc2d66a3dcedc2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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