Rem  Program:  dec2bin.bas
Rem  Program to Convert a positive integer(Max. 6 digits)
Rem   into equivalent binary.
MAXNUM = 999999
Do
  Input "Enter a positive integer:", number
  if (number >= 0 and number = int(number) and number <= MAXNUM) then exit do
  print "Invalid number"
Loop
Bin$ = ""
Do
   Digit = number mod 2
   If Digit = 0 then
     Bin$ = "0" + Bin$
   Else
     Bin$ = "1" + Bin$
   End If
   number = number \ 2
Loop Until number = 0
print using "Number in binary = &"; Bin$
End

