Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PROGRAM dec2bin;
- {asdasd}
- VAR
- num : integer;
- bin : Array[1..256] of char;
- n, c: integer;
- BEGIN
- c:=0;
- READLN(num);
- n := TRUNC(ln(num)/ln(2)+1); // El numero de bits que ocupa el número, mínimos.
- WHILE num>1 DO
- BEGIN
- // WRITE(num mod 2);
- bin[n-c] := CHR(num mod 2);
- num := num div 2;
- c:=c+1;
- END;
- // WRITELN(num);
- bin[1]:=CHR(num);
- FOR c:=1 TO n DO WRITE(bin[c]);
- END.
Add Comment
Please, Sign In to add comment