Sha256: d88f39aecf364c84fc2b2343fd4d548960fc09a4b0fd66a2a38a4803eab74eef

Contents?: true

Size: 1.54 KB

Versions: 10

Compression:

Stored size: 1.54 KB

Contents

==={{header|Applesoft BASIC}}===
Same code as [[#Commodore_BASIC|Commodore BASIC]]
==={{header|BaCon}}===
' Arthimetic/Integer
DECLARE a%, b%
INPUT "Enter integer A: ", a%
INPUT "Enter integer B: ", b%
PRINT

PRINT a%, " + ", b%, "     is ", a% + b%
PRINT a%, " - ", b%, "     is ", a% - b%
PRINT a%, " * ", b%, "     is ", a% * b%
PRINT a%, " / ", b%, "     is ", a% / b%, ", trucation toward zero"
PRINT "MOD(", a%, ", ", b%, ") is ", MOD(a%, b%), ", same sign as first operand"
PRINT "POW(", a%, ", ", b%, ") is ", INT(POW(a%, b%))

==={{header|Commodore BASIC}}===
10 INPUT "ENTER A NUMBER"; A%
20 INPUT "ENTER ANOTHER NUMBER"; B%
30 PRINT "ADDITION:";A%;"+";B%;"=";A%+B%
40 PRINT "SUBTRACTION:";A%;"-";B%;"=";A%-B%
50 PRINT "MULTIPLICATION:";A%;"*";B%;"=";A%*B%
60 PRINT "INTEGER DIVISION:";A%;"/";B%;"=";INT(A%/B%)
70 PRINT "REMAINDER OR MODULO:";A%;"%";B%;"=";A%-INT(A%/B%)*B%
80 PRINT "POWER:";A%;"^";B%;"=";A%^B%

==={{header|True BASIC}}===

! RosettaCode: Integer Arithmetic
! True BASIC v6.007
! Translated from BaCon example.
PROGRAM Integer_Arithmetic
	INPUT PROMPT "Enter integer A: ": a
	INPUT PROMPT "Enter integer B: ": b
	PRINT
	PRINT a;" + ";b;" is ";a+b
	PRINT a;" - ";b;" is ";a-b
	PRINT a;" * ";b;" is ";a*b
	PRINT a;" / ";b;" is ";INT(a/b);
	PRINT "MOD(";a;", ";b;") is "; MOD(a,b)
	PRINT "POW(";a;", ";b;") is ";INT(a^b)
	GET KEY done
END

==={{header|QBasic}}===
{{works with|QuickBasic|4.5}}
function math(a!, b!)
	print a + b
	print a - b
	print a * b
	print a / b
	print a mod b
end function
Truncate towards: 0

Remainder sign matches: first operand

Version data entries

10 entries across 7 versions & 1 rubygems

Version Path
zettacode-0.1.7 files.zettacode/arithmetic.integer/basic.txt
zettacode-0.1.6 files.zettacode/arithmetic.integer/basic.txt
zettacode-0.1.6 files.zettacode2/arithmetic.integer/basic.txt
zettacode-0.1.5 files.zettacode/arithmetic.integer/basic.txt
zettacode-0.1.5 files.zettacode2/arithmetic.integer/basic.txt
zettacode-0.1.4 files.zettacode/arithmetic.integer/basic.txt
zettacode-0.1.4 files.zettacode2/arithmetic.integer/basic.txt
zettacode-0.1.3 files.zettacode/arithmetic.integer/basic.txt
zettacode-0.1.2 files.zettacode/arithmetic.integer/basic.txt
zettacode-0.1.1 zettacode.files/arithmetic.integer/basic.txt