Jump to content

Arithmetic/Integer: Difference between revisions

→‎{{header|REXX}}: corrected statement about the sign of the remainder, added much whitespace in program and output. -- ~~~~
(adding maxima)
(→‎{{header|REXX}}: corrected statement about the sign of the remainder, added much whitespace in program and output. -- ~~~~)
Line 1,928:
 
=={{header|REXX}}==
<lang rexx>/*REXX pgm gets 2 integers from the console and displays various results*/
pad=left('',20) /*used for indenting the output. */
say "enter 2 integer values separated by blanks"
yields=' ───► ' /*use this to show "yields". */
parse pull a b
 
say a "+" b "=" a+b
say /*add a blank line to the output.*/
say a "-" b "=" a-b
say "enterEnter 2two integer values (separated by blanks):"
say a "*" b "=" a*b
 
say a "/" b "=" a%b "remaining" a//b "(sign from first operand)"
parse pull a b . /*or, could use: PULL A B . */
say a "^" b "=" a**b</lang>
 
say /*add a blank line to the output.*/
say pad a " + " b "="yields a+b
say pad a " - " b "="yields a-b
say pad a " * " b "="yields a*b
say pad a " / " b "="yields a%b "remaining" a//b "(sign from first2nd operand)"
say pad a "^** " b "="yields a**b</lang>
'''output'''
<pre>
<pre>enterEnter 2two integer values (separated by blanks):
17 -4
 
17 + -4 = 13
17 + -4 ───► 13
17 - -4 = 21
17 - -4 ───► 21
17 * -4 = -68
17 * -4 ───► -68
17 / -4 = ───► -4 remaining 1 (sign from first2nd operand)
17 ^ -4 = 0.0000119730367</pre>
17 ** -4 ───► 0.0000119730367
</pre>
 
=={{header|Ruby}}==
Cookies help us deliver our services. By using our services, you agree to our use of cookies.