Arithmetic/Integer: Difference between revisions

Content added Content deleted
(Add Brat solution)
m (Semi-automated edit: Deleted "Bash" (redundant with "UNIX Shell"))
Line 163: Line 163:
print ($1 % $2)
print ($1 % $2)
exit}</lang>
exit}</lang>
=={{header|Bash}}==
<lang bash>read -p "Enter x and y: " x y

echo "Sum: $((x+y))"
echo "Difference: $((x-y))"
echo "Product: $((x*y))"
echo "Quotient: $((x/y))" # truncates toward zero
echo "Remainder: $((x%y))" # same sign as first operand</lang>

=={{header|BASIC}}==
=={{header|BASIC}}==
{{works with|QuickBasic|4.5}}
{{works with|QuickBasic|4.5}}
Line 1,632: Line 1,623:


(Note: spaces inside the ''$((...))'' are optional and not required; the ''$((...))'' expressions can be inside the double quotes, but the `...` expressions could also have been enclosed in the double quotes in the previous example).
(Note: spaces inside the ''$((...))'' are optional and not required; the ''$((...))'' expressions can be inside the double quotes, but the `...` expressions could also have been enclosed in the double quotes in the previous example).

{{works with|Bash}}
<lang bash>read -p "Enter x and y: " x y

echo "Sum: $((x+y))"
echo "Difference: $((x-y))"
echo "Product: $((x*y))"
echo "Quotient: $((x/y))" # truncates toward zero
echo "Remainder: $((x%y))" # same sign as first operand</lang>


=={{header|Vedit macro language}}==
=={{header|Vedit macro language}}==