thedickblack

TRASPASO NUMERO BASE 10 A BINARIO

Aug 21st, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.38 KB | None | 0 0
  1. #include<math.h>
  2. #include<stdio.h>
  3. #include <stdlib.h>
  4. int main (void){
  5.  
  6.     unsigned long Numero,i,j,suma;
  7.     int vecAux[100];
  8.     check:
  9.     scanf("%lu",&Numero);
  10.     i=0;
  11.     while(Numero!=0){
  12.         vecAux[i]=Numero%2;
  13.         Numero=(Numero)/2;
  14.         i++;
  15.     }
  16.    
  17.     suma=0;
  18.    
  19.     for (j=0;j<i;j++){
  20.         suma = ( suma + (vecAux[j] * pow(10,j) ) );
  21.     }
  22.    
  23.      
  24.     printf("%lu",suma);
  25.     goto check;
  26.     return 0;
  27. }
Add Comment
Please, Sign In to add comment