Advertisement
Guest User

c_binaries

a guest
Nov 21st, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.51 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(){
  4. int numero_decimale, resto, n_volte, i, contatore;
  5. int numero_binario[contatore];
  6.  
  7. contatore = 0;
  8.  
  9. printf("inserisci il numero decimale");
  10. scanf("%d", &numero_decimale);
  11.  
  12. while(resto>0){
  13.   if (contatore==0){
  14.     n_volte = numero_decimale / 2;
  15.     resto = numero_decimale % 2;
  16.     numero_binario[contatore] = resto;
  17.   }
  18.   else if(contatore > 0){
  19.     n_volte = resto/2;
  20.     resto = resto/2;
  21.     numero_binario[contatore] = resto;
  22.   }
  23.   contatore++;  
  24. }
  25.  
  26.  
  27.   return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement