Arithmetic/Integer: Difference between revisions
Content added Content deleted
(VBScript entry) |
(Second implementation, python inspired) |
||
Line 1,138: | Line 1,138: | ||
wscript.echo "a mod b=", a mod b |
wscript.echo "a mod b=", a mod b |
||
wscript.echo "a ^ b=", a ^ b |
wscript.echo "a ^ b=", a ^ b |
||
</lang> |
|||
=====Another Implementation===== |
|||
Gives the same output for the same input. Inspired by Python version. |
|||
<lang vb> |
|||
option explicit |
|||
dim a, b |
|||
wscript.stdout.write "A? " |
|||
a = wscript.stdin.readline |
|||
wscript.stdout.write "B? " |
|||
b = wscript.stdin.readline |
|||
a = int( a ) |
|||
b = int( b ) |
|||
dim op |
|||
for each op in split("+ - * / \ mod ^", " ") |
|||
wscript.echo "a",op,"b=",eval( "a " & op & " b") |
|||
next |
|||
</lang> |
</lang> |
||