Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main() {
- int num, aux, i = 0, numAlg=0;
- printf("Digite um numero na base decimal: ");
- scanf("%d", &num);
- aux = num;
- while(aux > 0) {
- aux /= 10;
- numAlg++;
- }
- int bin[numAlg*4];
- aux = num;
- while(aux > 0) {
- bin[i] = aux%2;
- aux /= 2;
- i++;
- }
- printf("\nDecimal: %d\nBinario: ", num);
- for(int j = i-1; j >= 0; j--) printf("%d", bin[j], i);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement