Advertisement
tuki2501

dec2bin

Sep 7th, 2018
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.34 KB | None | 0 0
  1. uses crt;
  2.  
  3. procedure solve();
  4. var
  5.   bin:array[1..100] of longint;
  6.   n,d:longint;
  7. begin
  8.   write('dec: '); readln(d);
  9.   n:=0;
  10.   repeat
  11.     begin
  12.       inc(n);
  13.       bin[n]:=d mod 2;
  14.       d:=d div 2;
  15.     end;
  16.   until d=0;
  17.   write('bin: ');
  18.   for n:=n downto 1 do write(bin[n]);
  19. end;
  20.  
  21. begin
  22.   clrscr();
  23.   solve();
  24.   readln();
  25. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement