Arithmetic/Integer: Difference between revisions

No edit summary
Line 798:
 
=={{header|Elena}}==
<lang elena>#define std'basic'*system.
#define mathextensions'* = std'math'*io.
#define extensions'math.
 
#symbol// --- Program =---
 
#symbol program =
[
#var a := 'program'input >>consoleEx readLine:(Integer new).
#var b := 'program'input >>consoleEx readLine:(Integer new).
'program'outputconsoleEx << a << " + " << b << " = " << a + b << "%n".
'program'outputconsoleEx << a << " - " << b << " = " << a - b << "%n".
'program'outputconsoleEx << a << " * " << b << " = " << a * b << "%n".
'program'outputconsoleEx << a << " / " << b << " = " << a / b << "%n". // truncates towards 0
'program'outputconsoleEx << a << " %% " << b << " = " << a~math'eops math'(modulus:a:b) << "%n". // matches sign of first operand
].</lang>
 
Anonymous user