SHARE
TWEET

es 8.1

a guest Oct 21st, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. int main(){
  4.     // algoritmo senza usare un array
  5.     int b1=0,b2=0,b3=0,b4=0,b5=0,b6=0,b7=0,b8=0,n,coden;
  6.    
  7.     printf("Inserire un numero positivo tra 0 e 255\n");
  8.     coden=scanf("%d",&n);
  9.    
  10.     if((n<0)||(n>255)||(coden!=1)){
  11.         printf("Valore non valido\n");
  12.         return 1;
  13.     }
  14.  
  15.     b8=n%2;
  16.     n=n/2;
  17.     b7=n%2;
  18.     n=n/2;
  19.     b6=n%2;
  20.     n=n/2;
  21.     b5=n%2;
  22.     n=n/2;
  23.     b4=n%2;
  24.     n=n/2;
  25.     b3=n%2;
  26.     n=n/2;
  27.     b2=n%2;
  28.     n=n/2;
  29.     b1=n%2;
  30.  
  31.     printf("In binario รจ: %d%d%d%d%d%d%d%d \n",b1,b2,b3,b4,b5,b6,b7,b8);
  32.     return 0;
  33.    
  34. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top