# Assignment Help in Turbo 7.0 Pascal

can anyone help me write code to convert decimal numbers into binary numbers, i know very well how to do soo manually, its how to put my words into my program i need help with, am usuming i use the MOD function.....whatever the case i need some help. Thanks inadvance!

• I'm not sure what tools you have in TP, but here's a couple of algorithms in Basic ..

[code]
sub Bin(x:int)
' converts integer to binary (allowing for negative values) ..
def j:int
def s:string
j = x
if (j < 0) then j = j + 2147483647 + 1

do
s = ltrim\$(str\$(j % 2)) + s
j = j / 2
until j = 0

if (x < 0) then s = "1" + s
return s
endsub

sub Dec(s:string)
' converts binary string to integer ..
def i,result:int
result = 0
for i = 1 to len(s)
if mid\$(s,i,1) = "1" then result = result + 2 ^ (len(s) - i)
next i

return result
endsub
[/code]
• : can anyone help me write code to convert decimal numbers into binary
: numbers, i know very well how to do soo manually, its how to put my
: words into my program i need help with, am usuming i use the MOD
: function.....whatever the case i need some help. Thanks inadvance!