A+B: Difference between revisions
→{{header|Fennel}}
imported>PauliKL (→{{header|VBScript}}: Added Vedit macro language) |
|||
(16 intermediate revisions by 14 users not shown) | |||
Line 1,412:
=={{header|AWK}}==
<syntaxhighlight lang="awk">{print $1 + $2}</syntaxhighlight>
=={{header|BabyCobol}}==
* 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,552 ⟶ 1,567:
{{works with|Chipmunk Basic}}
{{works with|GW-BASIC}}
{{works with|IS-BASIC}}
{{works with|MSX Basic}}
{{works with|Just BASIC}}
Line 1,590 ⟶ 1,606:
50 GOTO 30
60 PRINT VAL A$( TO I-1)+VAL A$(I+1 TO )</syntaxhighlight>
==={{header|SmallBASIC}}===
<syntaxhighlight lang="SmallBASIC">
input "Enter number A: "; a
input "Enter number B: "; b
print "A + B = "; a + b
==={{Header|Tiny BASIC}}===
Line 1,638 ⟶ 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,786 ⟶ 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,282 ⟶ 2,339:
=={{header|EasyLang}}==
<syntaxhighlight
repeat
while i < len a$ and substr a$ i 1 <> " "▼
i += 1
.
a = number substr a$ 1 i
b = number substr a$ i
print a + b
</syntaxhighlight>
Line 2,662 ⟶ 2,720:
=={{header|Euler}}==
'''begin'''▼
▲<syntaxhighlight lang="euler">
'''out''' '''in''' + '''in'''▼
▲begin
'''end''' $▼
▲ out in + in
▲end $
▲</syntaxhighlight>
=={{header|Euler Math Toolbox}}==
Line 2,755 ⟶ 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,102 ⟶ 4,165:
20 INPUT "ENTER NUMBER B: ",B
30 PRINT A+B</syntaxhighlight>
=={{header|Nu}}==
<syntaxhighlight lang="nu">
input | parse "{a} {b}" | first | values | into int | math sum
</syntaxhighlight>
=={{header|Nutt}}==
Line 4,466 ⟶ 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,237 ⟶ 5,306:
More idiomatically:
<syntaxhighlight lang="ruby">say read(String).words»to_i
Explicit summation:
Line 5,909 ⟶ 5,978:
=={{header|Vedit macro language}}==
This version implements the task as specified in the task description.
<syntaxhighlight lang="vedit">
Get_Input(10, "Enter two integers separated by a space: ")
// Extract two numeric values from the text
Buf_Switch(Buf_Free)
Reg_Ins(10)
Line 5,915 ⟶ 5,987:
#1 = Num_Eval(ADVANCE)
#2 = Num_Eval()
Buf_Quit(OK)
Num_Type(#1 + #2)▼
▲Buf_Quit(OK)</syntaxhighlight>
// Calculate and display the results
▲Num_Type(#1 + #2)</syntaxhighlight>
A simpler version that prompts for the two numbers separately:
Line 6,041 ⟶ 6,115:
=={{header|Wren}}==
<syntaxhighlight lang="
while (true) {
|