A+B: Difference between revisions

1,328 bytes added ,  1 month ago
imported>Lacika7
(10 intermediate revisions by 10 users not shown)
Line 1,412:
=={{header|AWK}}==
<syntaxhighlight lang="awk">{print $1 + $2}</syntaxhighlight>
 
=={{header|BabyCobol}}==
<syntaxhighlight lang="eulercobol">
* NB: COBOL's ACCEPT does not work with multiple identifiers
IDENTIFICATION DIVISION.
PROGRAM-ID. PLUS.
DATA DIVISION.
01 A PICTURE IS S9999.
01 B LIKE A.
PROCEDURE DIVISION.
DISPLAY "Enter two numbers: " WITH NO ADVANCING.
ACCEPT A B.
ADD A TO B.
DISPLAY "A+B =" B.
</syntaxhighlight>
 
=={{header|BASIC}}==
Line 1,646 ⟶ 1,661:
Loop
Return (b@)</syntaxhighlight>
 
==={{header|XBasic}}===
{{works with|Windows XBasic}}
<syntaxhighlight lang="qbasic">PROGRAM "A+B"
VERSION "0.0000"
 
DECLARE FUNCTION Entry ()
 
FUNCTION Entry ()
a$ = INLINE$("Enter integer A: ")
a = SLONG(a$)
b$ = INLINE$("Enter integer B: ")
b = SLONG(b$)
DO WHILE 1
IF ABS(a) > 1000 OR ABS(b) > 1000 THEN
PRINT "Both integers must be in the interval [-1000..1000] - try again."
PRINT
ELSE
PRINT "Their sum is"; a + b
EXIT DO
END IF
LOOP
END FUNCTION
END PROGRAM</syntaxhighlight>
 
=={{header|Batch File}}==
Line 1,794 ⟶ 1,833:
<syntaxhighlight lang="brat">numbers = g.split[0,1].map(:to_i)
p numbers[0] + numbers[1] #Prints the sum of the input</syntaxhighlight>
 
=={{header|Bruijn}}==
<syntaxhighlight lang="bruijn">
:import std/Combinator .
:import std/String .
:import std/Number .
:import std/Char C
 
main (split-by (C.eq? ' ')) → &(add ⋔ string→number)
</syntaxhighlight>
 
=={{header|Burlesque}}==
Line 2,290 ⟶ 2,339:
 
=={{header|EasyLang}}==
<syntaxhighlight lang="text">a$ = input
ia$ = 1input
repeat
while i < len a$ and substr a$ i 1 <> " "
i += 1
while until i <> len a$ andor substr a$ i 1 <>= " "
.
a = number substr a$ 1 i
b = number substr a$ i -199
print a + b
</syntaxhighlight>
Line 2,606 ⟶ 2,656:
 
=={{header|EMal}}==
<syntaxhighlight lang="ecmascriptemal">
fun main = int by List args
text input = when(args.length == 1, args[0], ask(text, "Enter n integers separated by a space: "))
Line 2,670 ⟶ 2,720:
 
=={{header|Euler}}==
'''begin'''
<syntaxhighlight lang="euler">
'''out''' '''in''' + '''in'''
begin
'''end''' $
out in + in
end $
</syntaxhighlight>
 
=={{header|Euler Math Toolbox}}==
Line 2,763 ⟶ 2,811:
 
PAUSE</syntaxhighlight>
 
=={{header|Fennel}}==
{{trans|Lua}}
<syntaxhighlight lang="fennel">
(let [(a b) (io.read :*number :*number)]
(print (+ a b)))
</syntaxhighlight>
 
=={{header|Fhidwfe}}==
Line 4,479 ⟶ 4,534:
</pre>
=== GUI version ===
{{libheader|Phix/pGUI}}
<small>(The above console version is now just a comment in the distributed file.)</small>
<!--<syntaxhighlight lang="phix">(phixonline)-->
Line 5,250 ⟶ 5,306:
 
More idiomatically:
<syntaxhighlight lang="ruby">say read(String).words»to_i»()»«+»</syntaxhighlight>
 
Explicit summation:
Line 6,059 ⟶ 6,115:
 
=={{header|Wren}}==
<syntaxhighlight lang="ecmascriptwren">import "io" for Stdin, Stdout
 
while (true) {
62

edits