{{works with|GNU Smalltalk}}
| a b |
'Input number a: ' display.
a := (stdin nextLine) asInteger.
'Input number b: ' display.
b := (stdin nextLine) asInteger.
('a+b=%1' % { a + b }) displayNl.
('a-b=%1' % { a - b }) displayNl.
('a*b=%1' % { a * b }) displayNl.
('a/b=%1' % { a // b }) displayNl.
('a%%b=%1' % { a \\ b }) displayNl.
{{works with|Smalltalk/X}} (and all other Smalltalks)
|a b|
a := (Dialog request:'Enter first number:') asNumber.
b := (Dialog request:'Enter second number:') asNumber.
#( + - / * // \\ quo: rem: raisedTo: **) do:[:operator |
|result|
result := a perform:operator with:b.
'%P %s %P => %P\n' printf:{a . operator . b . result} on:Transcript
].
/ is exact division
// is truncating division (towards negative infinity)
\\ is remainder from \\
quo: is truncating division (towards zero)
\\ is remainder from quo:
** is just an alias for raisedTo:
Entering 10 and 3, generates: