SHARE
TWEET

es 8.2

a guest Oct 21st, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.     int base,code;
  6.    
  7.     printf("Inserire una base\n");
  8.     code=scanf("%d",&base);
  9.    
  10.     if((base<0)||(code!=1)){
  11.         printf("Valore non valido\n");
  12.         return 1;
  13.     }
  14.    
  15.     int b1=0,b2=0,b3=0,b4=0,b5=0,b6=0,b7=0,b8=0,n,coden;
  16.    
  17.     printf("Inserire un numero positivo tra 0 e 255\n");
  18.     coden=scanf("%d",&n);
  19.    
  20.     if((n<0)||(n>255)||(coden!=1)){
  21.         printf("Valore non valido\n");
  22.         return 1;
  23.     }
  24.  
  25.     b8=n%base;
  26.     n=n/base;
  27.     b7=n%base;
  28.     n=n/base;
  29.     b6=n%base;
  30.     n=n/base;
  31.     b5=n%base;
  32.     n=n/base;
  33.     b4=n%base;
  34.     n=n/base;
  35.     b3=n%base;
  36.     n=n/base;
  37.     b2=n%base;
  38.     n=n/base;
  39.     b1=n%base;
  40.  
  41.     printf("In base %d è: %d %d %d %d %d %d %d %d \n",base,b1,b2,b3,b4,b5,b6,b7,b8);
  42.     return 0;
  43.  
  44. }
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