Advertisement
Guest User

Перевод в двоичную систему

a guest
Mar 20th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(){
  4. int x,y,z,n,b;
  5. printf("Enter number :");
  6. scanf("%d",&x);
  7.  
  8. y=x;
  9. z=0;
  10.  
  11. while (y){
  12. y=y/2;
  13. z++;
  14. }
  15.  
  16. b=z-1;
  17. printf("Amount of numbers :%d\n",z);
  18.  
  19. int a[z];
  20.  
  21. while (x){
  22. // printf("%d",x%2);
  23. a[z-b]=x%2;
  24. b=b-1;
  25. x=x/2;
  26. }
  27. //printf("\n");
  28. printf("Your number :");
  29.  
  30. while (z){
  31. printf("%d",a[z]);
  32. z=z-1;
  33. }
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement