Arithmetic/Integer: Difference between revisions
Content added Content deleted
(→{{header|REXX}}: changed the program (for validating the input), add/changed comments and whitespace.) |
|||
Line 2,621:
=={{header|REXX}}==
<lang rexx>/*REXX pgm gets 2 integers from the C
numeric digits 20 /*
parse arg x y . /*maybe the integers are on the C.L.
parse arg x y . /*maybe the integers are on C.L.?*/▼
if y=='' then do /*nope, then prompt user for 'em.*/▼
say "─────Enter two integer values (separated by blanks):"▼
do 2 /*show A with B, then B with A.*/▼
say /*show blank line for eyeballing.*/▼
do while \datatype(x,'W') | \datatype(y,'W') /*both X and Y must be ints.*/
call show 'addition' , "+", x+y▼
call show 'subtraction' , "-", x-y▼
call show 'multiplication', "*", x*y▼
call show 'int division' , "%", x%y, ' [rounds down]'▼
call show 'real division' , "/", x/y▼
call show 'div remainder' , "//", x//y, ' [sign from 1st operand]'▼
call show '
parse value x y with y x /*swap the two values
if j==1 then say copies('═', 79) /*display a fence after the 1st round. */
▲ end /*2*/
end /*j*/
/*────────────────────────────────────────────────────────────────────────────*/
show: parse arg c,o,#,?; say right(
'''output''' when using the input of: <tt> 17 -4 </tt>▼
▲'''output''' when using the input of: <tt> 17 -4 </tt>
<pre>
addition
subtraction
multiplication
int division
real division
power
═══════════════════════════════════════════════════════════════════════════════
addition -
subtraction -
multiplication -
int division -
real division -
power -
</pre>
|