Guest User

Untitled

a guest
Oct 20th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. //20_10_17
  2. //Crehul Vlad
  3. //Base conversion: Decimal into Binary
  4. #define _CRT_SECURE_NO_WARNINGS
  5.  
  6. #include <stdio.h>
  7.  
  8. void main() {
  9. int k=0, i, r, nr, c, N[64];
  10. printf("Decimal Nr: "); scanf("%d", &nr);
  11. c = nr;
  12. while (nr % 2 != 0) {
  13. r = c % 2;
  14. c = c / 2;
  15. N[k] = r; k++;
  16. }
  17. for (i = k; i > 0; i--) {
  18. printf("%d ", N[i]);
  19. }
  20.  
  21. _getch();
  22. return 0;
  23. }
Add Comment
Please, Sign In to add comment