Wednesday, February 4, 2009

Change Desimal to Binner

When we studied about 'pemrograman sistem digital',there are lesson about 'sistem billangan'.
In there we need skill to conversion one type of number to other type.
One of them is change circle number to binner number.
For example :
1=1
2=01
3=001
4=101

5=110

To finish that case,we can use statement like this :

uses wincrt;
var bil,b : integer;
b2 : char;
hasil : string;

begin
writeln('write a decimal number : ');readln(bil);
while bil>=1 do
begin
b:=bil mod 2;
bil:=bil div 2;
if b=1 then b2:='1' else b2:='0';
hasil:=hasil+b2;
end;
writeln('binner number of it: ',hasil)
end.

if we run the statement,we are get output like this :

binner

No comments: