Guest User

Untitled

a guest
Apr 19th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.29 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3.  
  4.  
  5. int main(){
  6.     int nPes=64,nValor;
  7.    
  8.     printf("Introdueix un nombre en binari:  ");
  9.     scanf("%d",&nValor);
  10.    
  11.     while(nPes){
  12.         if(nValor>=nPes){
  13.             nValor-=nPes;
  14.             printf("1");
  15.         }
  16.         else{
  17.             printf("0");
  18.         }
  19.         nPes/=2;
  20.     }
  21.    
  22.     printf("\n");
  23.    
  24.     return 0;
  25. }
Add Comment
Please, Sign In to add comment