Biner to Desimal

Posted on 18.06.2010

0


program biner2desimal(Output);
uses crt;
type
   a=0..1;
var
   biner : array[1..1000] of a;
   n,i,j : integer;
begin
   clrscr;
   write(‘desimal : ‘); readln(n);

   i:=1;
   repeat
      biner[i]:= n mod 2;
      n:= n div 2;
      inc(i);
   until (n=1);
   biner[i]:=1;

   writeln;
   write(‘Nilai Biner : ‘);
   for j:=i downto 1 do begin
      write(biner[j]);
   end;
   writeln;
   readln;
end.

Posted in: Pascal Code