Calculator (program form)
A calculator is a common popular problem used to test the effectiveness of a programming language at implementing a usable program. The goal of a calculator is simple, emulating the behavior of the electronic device by taking two numbers and an operation (in any order), and outputting the result. The scope of a calculator is typically limited to the four basic arithmetic operations (addition, subtraction, multiplication, and division/modulus).
An interaction with a calculator would be as follows:
Input first number > 5 Input second number > 9 Input operation > * 45
For languages which do not support IO or inputting characters, a constant corresponding to each of the operations is commonly used instead.
> 45 > 5 > 4 (as in division) 9
Implementations
- This article is not detailed enough and needs to be expanded. Please help us by adding some more information.
'Python' is not recognized as an internal or external command, operable program or batch file.
#2@ x = input() if x == '+': print(input()+input()) else: print(input()-input()) #A
!English
Start of this part: Menu Print "This is the calculator!" and a new line Print "Made in the !English programming language!" and a new line Print "What to do?" and a new line Print "1. Addition" and a new line Print "2. Subtraction" and a new line Print "3. Multiplication" and a new line Print "4. Division" and a new line Print "5. Modulo" and a new line Print "6. Power" and a new line Give me x as input If x is 1: Jump to the addition part of the code If x is 2: Jump to the subtraction part of the code If x is 3: Jump to the multiplication part of the code If x is 4: Jump to the division part of the code If x is 5: Jump to the modulo part of the code If x is 6: Jump to the power part of the code End of this part: Menu Start of this part: Addition Give me x as input Give me y as input Declare z as a addition of x and y Print the value of z and a newline End of this part: Addition Start of this part: Subtraction Give me x as input Give me y as input Declare z as a subtraction of x and y Print the value of z and a newline End of this part: Subtraction Start of this part: Multiplication Give me x as input Give me y as input Declare z as a multiplication of x and y Print the value of z and a newline End of this part: Multiplication Start of this part: Division Give me x as input Give me y as input Declare z as a division of x and y Print the value of z and a newline End of this part: Division Start of this part: Modulo Give me x as input Give me y as input Declare z as a modulo of x and y Print the value of z and a newline End of this part: Modulo Start of this part: Power Give me x as input Give me y as input Declare z as a power of x and y Print the value of z and a newline End of this part: Power
?
++++++^pc++p+x++pc++++++p+t----p-x++pc++pc+x+v++++++++++p-vp++++++p m(++++)m(++++)m(++++)m(++++)m(++++)m(++++)m(++++)m(++++)m(++++)m(++++)m(++++)m(++++)m(++++)m(++++)m(++++)m(++++)m(++++)m(++++)m(++++)m(++++)m(++++) +v^p+x--pc+x+v++++++++++pc+vp+x++++++p_c+v++p++++++p+x--p++pc+x+v++++++++++p_-v--p+v++++p-x++++pc++++pc+vp+x++++++ps(+v)?+ +v^p+x--pc+x+v++++++++++pc+vp+x++++++p_++pc+vp----p+x++++p--pc+v--p_+xp+v++++p-x++++pc++++pc+vp+x++++++ps(+v)?+ +t----^pc+vp+x+v--p++++p-x++pc+x+v++++++++++ps(+v) !++p_m(++)_!++-p_m(+v)_!+-p !++p_m(++++)_!++-p_m(+v)_!+-+p !++p_m(++++++)_!++-p_m(+v)_!+--p !++p_m(+v--)_!++-p_m(+v)_!+-++p
1=0
55586=;
55587=;
55588=?
88843={
55586+=55587
}
88845={
55586-=55587
}
88842={
55586*=55587
}
88847={
55586/=55587
}
88837={
55586%=55587
}
905050=88800
905050+=55588
:55586
4est
Visit the 3rd tree.
Propagate the 1st tree 3 times.
Propagate the 2nd tree 4 times.
Propagate the 3rd tree 5 times.
Fly over the 1st 1st tree.
Take recommendations.
Fly over the 1st 2nd tree.
Take advice.
Fly over the 1st 3rd tree.
Take recommendations.
Fly over the 2nd 1st tree.
Graft the tree 43 times.
Fly over the 2nd 2nd tree.
Graft the tree 45 times.
Fly over the 2nd 3rd tree.
Graft the tree 42 times.
Fly over the 2nd 4th tree.
Graft the tree 47 times.
Fly over the 3rd 1st tree.
Graft the tree 69 times.
Fly over the 3rd 2nd tree.
Graft the tree 82 times.
Graft the 3rd 2nd tree in the mother forest to the 3rd 3rd tree in the mother forest.
Fly over the 3rd 4th tree.
Graft the tree 79 times.
Graft the 3rd 2nd tree in the mother forest to the 3rd 5th tree in the mother forest.
If the 1st 2nd tree in the mother forest is as strong as the 2nd 1st tree in the mother forest.
Plant the 1st 3rd sapling around the 1st 1st tree.
Sterilize tools.
Or else.
If the 1st 2nd tree in the mother forest is as strong as the 2nd 2nd tree in the mother forest.
Destroy the 1st 3rd sapling around the 1st 1st tree.
Sterilize tools.
Or else.
If the 1st 2nd tree in the mother forest is as strong as the 2nd 3rd tree in the mother forest.
Spray the 1st 3rd sapling around the 1st 1st tree.
Sterilize tools.
Or else.
If the 1st 2nd tree in the mother forest is as strong as the 2nd 4th tree in the mother forest.
Decimate the 1st 3rd sapling around the 1st 1st tree.
Sterilize tools.
Or else.
Fly over the 3rd 1st tree.
Give advice.
Fly over the 3rd 2nd tree.
Give advice.
Fly over the 3rd 3rd tree.
Give advice.
Fly over the 3rd 4th tree.
Give advice.
Fly over the 3rd 5th tree.
Give advice.
Sterilize tools.
Sterilize tools.
Sterilize tools.
Sterilize tools.
4s (Four Stacks)
&&>>%>+'0'+'4':[@;)]^<;>?:[,<<{/}*+\n--.|]<;>?:[,<<{*}*+\n--.|]<;>?:[,<<{-}*+\n--.|]<;>?:[,<<{+}*+\n--.|]
9f87m4atttaaaou;
,i,z67mswrm.h:pwra.h:2awrzs.h:2awrzd.h:
█
⍥>ᴟᴞ〷ᴞ¿【⍴⨧⍵⍴】𝟘?>⁋`÷`█⁋⍥¿【⍴÷⍴】𝟘?【⍴÷⅟⍴】
aboba
(1 and 2 is numbers, 3 is operator)
%1 in sp %2 in sp sw %3 ic [43 s+ sg ) ~] [45 s- sg ) ~] [42 s* sg ) ~] [47 s/ sg ) ~] %0 +73 ( +37 ( +8 ( -21 ( +11 ( -3 ( -5 ( -67 ( ~
Amino
TACTAATAGCTAGTCAAACTCTCCAAGAGTATGGATAAGCCTCTTAAGCCATTTGGTGTCAAGCTCCTCAAGAGCATGGATAAGCCCTCCAAACCTTTTGGTGTCAAACTCTCTAAATCAATGGAAAAATTCTTTTCTAAACCATTCGGGGTTAAGCTCCCCAAGAGGATGGATAAATTCTTCTTCAAACCTTTCGGTAAATTCTTCCTCAAGCCGGGCGGTCGGCATAAGTTCTTCCTCAAGCCTGGAGGTAGGCAAAAATTCTTCCTCAAGCCGGGTGGGTGTCACAAATTCTTCCTCAAGCCGGGCGGGGTGCAGACT
Ampell
^"a="~a^"b="~b^"+, -, *, or /?"~f&[f]&["+"]=[&[a]&[b]+$]&[f]&["-"]=[&[a]&[b]-$]&[f]&["*"]=[&[a]&[b]*$]&[f]&["/"]=[&[a]&[b]/$]&[f]&["+"]![&[f]&["-"]![&[f]&["*"]![&[f]&["/"]![&["invalid args"]$]]]]
AnnoyingScript
+C+a+l+c+u+l+a+t+o+r<:~->~+E+n+t+e+r+ +O+p+e+r+a+t+o+r+ +(+ +++ +-+ +*+ +/+ +%+ +)<:~-_~-=+F+i+r+s+t+ +N+u+m+b+e+r<:~-_~-=+S+e+c+o+n+d+ +N+u+m+b+e+r<:~-_~-=+@2+@3&@1~->~
Backsharp
&&.p.r.o.g.r.a.m. :> [@]=>.m.e.t.a.:.c.l.e.a.r. \\this clears the console completely. [@]=>.^c.h.o.o.s.e.+.a.n.+.o.p.e.r.a.t.o.r.:. [@]=>.^a.d.d.,.+.s.u.b.,.+.m.u.l.t.,.+.d.i.v... #[.o.p.e.r.a.t.o.r.]<=.$. [@]=>.^i.n.p.u.t.+.n.u.m.b.e.r.+.1... #[m]<=.$. [@]=>.^i.n.p.u.t.+.n.u.m.b.e.r.+.2... #[n]<=.$. #[x]=>[m][.o.p.e.r.a.t.o.r.][n] [@]=>.^r.e.s.u.l.t.:.+.[.x.]. <:
Befunge
Type 1 to add, 2 to subtract, 3 to multiply, 4 to divide.
"rotaluclaC egnufeB">:v
|,<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>52*:,,"/4 *3 -2 +1">:v ^^^^
|,< ^^^^
>52*:,,v^^^^
v<<<<<<<^^^^
& ^^^^
: ^^^^
1 ^^^^
- ^^^^
v_$&&+.$>^^^^
: ^^^
2 ^^^
- ^^^
v_$&&-.$>>>^^^
: ^^
3 ^^
- ^^
v_$&&*.$>>>>>^^
: ^
4 ^
- ^
@_$&&/.$>>>>>>>^
Betterfunge
Type 1 to add, 2 to subtract, 3 to multiply, 4 to divide, 5 for power and 6 for square root.
[‘‘+]A₩[‘‘$-]S₩[‘‘×]M₩[‘‘$÷]D₩[‘‘$*]P₩[‘√]R₩‘1-[A¥:0q][]?1-[S¥:0q][]?1-[M¥:0q][]?1-[D¥:0q][]?1-[P¥:0q][]?1-[R¥:0q][]?"Error: invalid operation"[;]@q C
Bidiroop
Class OperatorConstruct
Method a, op
Return <C>(("Function apply, Integer a, Integer b\n Return a " +* op) +* " b\nMethod m, Integer a, Integer b\n Print <F>[apply][a, b]\n return <C>(\"\")")
Function main
InputInteger arga
InputString operator
InputInteger argb
Set o, OperatorConstruct[]
Set C, <M>[o][a][operator]
Set oo, C[]
Set mrun, <M>[oo][m][arga, argb]
Bolaga
>0
>32>58>114>101
>98>109>117>110
>32>116>115>114
>105>102>32>101
>104>116>32>116
>117>112>110>73
:@;<^
>0
>32>58>114>101
>98>109>117>110
>32>100>110>111
>99>101>115>32
>101>104>116>32
>116>117>112>110>73
:@;<^
>0
>32>58>41>47>32>44>42
>32>44>45>32>44>43>40
>32>110>111>105>116>97
>114>101>112>111>32>110
>97>32>114>101>116>110>69
:@;<#
>43?:>0
$+%$
;<
>45?:>0
$-%$
;<
>42?:>0
>0$:
>1>0-+$>1+$;<>1>0-+>0$
:>1>0-+$>1+$;<$=$>0$
:>1>0-+$>1+$;<$>0$:>1>0-+
$>1+$;<:>1>0-+>0$:>1>0-+$
>1+$;<$>0$:>1>0-+$>1+$;<$
=$>0$:>1>0-+$>1+$;<+$>0$:
>1>0-+$>1+$;<;<>0$:>1>0-+$
>1+$
;<<$%$
;<
>47?:>0
>0$:
$>0$:>1>0-+$>1+$;<=>0$
:>1>0-+$>1+$;<$-$>1+$;
<<>0$:>1>0-+$>1+$
;<$%$
;>10@&!
Circle of Life
Loop {
Adam MakeVar "Operation"
Adam Split "Ask", "Functions"
Ask SetVar Operation [input|"Operation? 1 for addition, 2 for subtraction"]
Ask Die
Functions Split "Add", "Subtract"
If Operation = 1 {
Add Split "GetNumsA", "AddFunc"
GetNums Split "Num1A", "Num2A"
Num1A MakeVar "AddVar1"
Num1A SetVar AddVar1 [Input|First Number?]
Num2A MakeVar "AddVar2"
Num2A SetVar AddVar2 [Input|Second Number?]
AddFunc Split "AddFinal", "PrinterA"
AddFinal MakeVar "LastA"
AddFinal Add AddVar1 AddVar2 LastA
PrinterA Write LastA
PrinterA Sunder
}
If Operation = 2 {
Sub Split "GetNumsS", "SubFunc"
GetNums Split "Num1S", "Num2S"
Num1S MakeVar "SubVar1"
Num1S SetVar SubVar1 [Input|First Number?]
Num2S MakeVar "SubVar2"
Num2S SetVar SubVar2 [Input|Second Number?]
SubFunc Split "SubFinal", "PrinterS"
SubFinal MakeVar "LastS"
SubFinal Sub SubVar1 SubVar2 LastS
PrinterS Write LastS
PrinterS Sunder
}
}
Circuits V1
Comp
;;' \43[%+_] \45[%-_] \42[%*_] \47[%/_]
CreativeASM
@ A calculator program in CreativeASM lbl main @ Lines of text to be printed clr put rax "Welcome to CreativeCalc, version 1" int rax 01h put rax "What to do?" int rax 01h put rax "1. Add" int rax 01h put rax "2. Subtract" int rax 01h put rax "3. Multiply" int rax 01h put rax "4. Divide" int rax 01h @ Input int rbx 00h @ Jumping beqrbx 1 add beqrbx 2 subtract beqrbx 3 multiply beqrbx 4 divide @ Label for Add lbl add clr int ra 00h int rb 00h add ra rb rc put rd "The result is:" int rd 01h int rc 01h slp jmp main @ Label for Subtract lbl subtract clr int ra 00h int rb 00h sub ra rb rc put rd "The result is:" int rd 01h int rc 01h slp jmp main @ Label for Multiply lbl multiply clr int ra 00h int rb 00h mul ra rb rc put rd "The result is:" int rd 01h int rc 01h slp jmp main @ Label for Divide lbl divide clr int ra 00h int rb 00h div ra rb rc put rd "The result is:" int rd 01h int rc 01h slp jmp main
Assembled to Batch
@echo off set ra= set rb= set rc= set rd= REM Another set set rax= set rbx= set rcx= set rdx= REM Special ones set r= set s= set t= set u= REM x86 assembly ones set eax= set ebx= set ecx= set edx= REM A calculator program in CreativeASM :main REM Lines of text to be printed cls set rax="Welcome to CreativeCalc, version 1" echo %rax% set rax="What to do?" echo %rax% set rax="1. Add" echo %rax% set rax="2. Subtract" echo %rax% set rax="3. Multiply" echo %rax% set rax="4. Divide" echo %rax% REM Input set /p rbx=? REM Jumping if %rbx% EQU 1 goto add if %rbx% EQU 2 goto subtract if %rbx% EQU 3 goto multiply if %rbx% EQU 4 goto divide REM Label for Add :add cls set /p ra=? set /p rb=? set /a rc=%ra%+%rb% set rd="The result is:" echo %rd% echo %rc% pause >nul goto main REM Label for Subtract :subtract cls set /p ra=? set /p rb=? set /a rc=%ra%-%rb% set rd="The result is:" echo %rd% echo %rc% pause >nul goto main REM Label for Multiply :multiply cls set /p ra=? set /p rb=? set /a rc=%ra%*%rb% set rd="The result is:" echo %rd% echo %rc% pause >nul goto main REM Label for Divide :divide cls set /p ra=? set /p rb=? set /a rc=%ra%/%rb% set rd="The result is:" echo %rd% echo %rc% pause >nul goto main
Cubed
42 * 43 + 45 - 47 /
|r|r|r|r|”|4|3|”|?|=|d| |2|!|<|l|l|l|l|l|l|l|l| |#|#|r|?|?|:|d|#|#|#|#| |#|#|@|p|l|+|l|#|#|#|#|
|r|r|r|r|”|4|5|”|?|=|d| |3|!|<|l|l|l|l|l|l|l|l| |#|#|r|?|?|:|d|#|#|#|#| |#|#|@|p|l|-|l|#|#|#|#|
|r|r|r|r|”|4|2|”|?|=|d| |4|!|<|l|l|l|l|l|l|l|l| |#|#|r|?|?|:|d|#|#|#|#| |#|#|@|p|l|*|l|#|#|#|#|
|r|r|r|r|”|4|7|”|?|=|d| |t|!|<|l|l|l|l|l|l|l|l| |#|#|r|?|?|:|d|#|#|#|#| |#|#|@|p|l|/|l|#|#|#|#|
dolfins grace
/$$??`#W
/$$$$$??*#W
/$$$$$$$??-#W
/$$$$$$$$$$$??+#W
S?1[$2[$3[$4[$$??%#W @
@ /WS
>"five function calculator"A^!A
Dot's
.--------(l changeuit`( "enter math symbol: "`))-(e main)
.-(c main)-?-*-7 -*-*-*-------=-#reset#---------------------------------------------\
| | | | |
| 2 4 6 |
| |
| | /--(l changeuit`( "enter number: "`))-(e add) |
*-#+#----[=]---------:--------------------------------------------------\ |
| | /--(l changeuit`( "enter number: "`))-(e tak) | =
*-#`-#-----[=]-------:------------------------------------------------\ | |
| | /--(l changeuit`( "enter number: "`))-(e mul) >->-[004]------$Invaild-Input-Restarting-Main-Function$-(e main)
/-=--*-#*#--------[=]-----:------------------------------------------------/ |
| | /--(l changeuit`( "enter number: "`))-(e div) |
| >-#/#-----------[=]--:--------------------------------------------------/
\-------------------=-/
.--(c add)-*--?-4 -v
| [ton]
>-?-[ton][+]--$#$--(l changeuit`( "enter math symbol: "`))-(e main)
.---(c tak)-*--?-4 -v
| [ton]
>-?-[ton][-]--$#$--(l changeuit`( "enter math symbol: "`))-(e main)
.----(c mul)-*--?-4 -v
| [ton]
>-?-[ton][*]--$#$--(l changeuit`( "enter math symbol: "`))-(e main)
.-----(c div)-*--?-4 -v
| [ton]
>-?-[ton][/]--$#$--(l changeuit`( "enter math symbol: "`))-(e main)
Egnufeb
v <
>if(v=s)[|]v
v <
>i{a}i{b}iv
v <
>f(v=+)[a+b]f(v=-)[a-b]f(v=*)[a*b]f(v=/)[a/b]f(v=^)[a^b]f(v=%
Elevator
; There are three elevators: one for the first number and the result, one for the operation and one for the second number
elevator A
action main
getFloor ; Get the first number
end action
end elevator
elevator Op
action main
getFloor ; Get the operation
end action
end elevator
elevator B
action main
getFloor ; Get the second number
; Check the operation
with Op
in 1
; add
with A
up !
outFloor
end with
end in
in 2
; Substract
with A
down !
outFloor
end with
end in
end with
end action
end elevator
Cleaner Version
; In this version there is instead a controller, a math, and a storage elevator
elevator Controller
; When the program starts:
action main
; Get the first number
getFloor
; Store it into the storage
with Storage
store !
end with
; Get the operation
getFloor
; If its one, then get the second number an add it to the storage
in 1
with Math
getFloor
addToStorage
end with
end in
; If its 2 substract it to the storage
in 2
with Math
getFloor
substractToStorage
end with
end in
; Print the result
with Storage
outFloor
end with
end action
end elevator
elevator Storage
action store val
floor val
end action
end elevator
elevator Math
action addToStorage
with Storage
up !
end with
end action
action substractToStorage
with Storage
down !
end with
end action
end elevator
Empty
∅^∅•∅bSpI`+I10`:∅5^∅•∅eSsI`-I10`:∅5^∅•∅eSmI`•∅10^∅10•I20`:∅5^∅•∅eSdI`•I10`∅5^∅•∅eSb模 模TbIRoTpTsTmTd-"++"1`-∅5^∅;∅pRoI-"-+"1`-∅5^∅;∅sIRoI-x+"1`-∅5^∅;∅mRoI-"/+"1`-∅5^∅;∅dSeTe
EXDotSF
,..~_#c+=[[]+:z]_#c-=[[]-:z]_#c*=[[]*:z]_#c/=[[]/:z]#n10\#n13\#cR#cO#cR#cR#cE;;;;;;;Z
Fish
Input structure goes like: "{int}{operator}{int}=" and in char mode.
01-2.;;;>?!vc4*-{a*+}!;v~;n;
;v~~:~:<~|.!~,+a<bc6-10<;;;;
i :1+?!^!;:~:~:~:~:~:~:~:~:~
v>r!;:~>:~!v!;!;!;!;!;!;!;!;
\0}0&:~!!>!|474159+,-,*~!;!;
v!~:)-10\*@|!@-1=+1*a6:$;!;!
>:c4*-!;^;;>&:?v~&:~>>0}!;!;
v<;!;!~:~:&$&~$<;;;;;;;;;n;;
>5:*0p64*0.;;;;;;;;;;;;;;,;;
FlinnScrip
define(0){
print("CALCULATOR\n");
print("Which math do you want to choose?\n");
print("1 = Addition & Subtraction\n");
print("2 = Multiply\n");
print("3 = Division");
input(0);
if(0=1){
print("Enter the first number");
input(1);
print("Enter the second number");
input(2);
ifcontain(1,str||2,str){
print("Your input shouldnt have words!");
pause;
returnend;
};
add(1,var(2));
print(var(1));
pause;
};
if(0=2){
print("Enter the first number");
input(1);
print("Enter the second number");
input(2);
ifcontain(1,str||2,str){
print("Your input shouldnt have words!");
pause;
returnend;
};
multiply(1,var(2));
print(var(1));
pause;
};
if(0=3){
print("Enter the first number");
input(1);
print("Enter the second number");
input(2);
ifcontain(1,str||2,str){
print("Your input shouldnt have words!");
pause;
returnend;
};
divide(1,var(2));
print(var(1));
pause;
};
};
set(3,1);
while(3>=1){
if(3=1){call(0);};
set(3,2);
clear;
print("Again? Y/N")
input(4);
if(4="y"){set(3,1);};
if(4="n"){set(3,0);};
};
FlipJump

For The Worthy
0001 10 0 00000000 0001 10 0 00000001 0001 11 0 00000010 0011 00000000 0011 00000010 0011 00000001 0100 001 00000010 1000 100 00101011 0010 10 001 00000000 0000 001 00000001 0101 0100 001 00000010 1000 100 00101101 0010 10 001 00000000 0001 001 00000001 0101 0100 001 00000010 1000 100 00101010 0010 10 001 00000000 0010 001 00000001 0101 0100 001 00000010 1000 100 00101111 0010 10 001 00000000 0011 001 00000001 0101
Free2Edit
With comments
dsdcws-1wede pCpaplpcpuplpaptpopr+5+5oc-5-5 #Prompt for X# pXp:p gnonl1+5+5oc-5-5r1 #Prompt for Y# r1pYp:p gnonl2+5+5oc-5-5r2 #Prompt for Operation# r1pOppp:p gcocr1+5+5oc-5-5l1 r1+1l1-9-9-9-9-7isr1-1l1ie+9+9+9+9+7r1isl3+conr3-1ie #Checks if operation is +. If so, add X and Y and output it. else...# +1l1-9-9-9-9-9isr1-1l1ie+9+9+9+9+9r1isl3-conr3-1ie #Checks if operation is -. If so, subtract X and Y and output it. else...# +1l1-9-9-9-9-6isr1-1l1ie+9+9+9+9+6r1isl3*conr3-1ie #Checks if operation is *. If so, multiply X and Y and output it. else...# +1l1-9-9-9-9-9-2isr1-1l1ie+9+9+9+9+9+2r1isl3/conr3-1ie #Checks if operation is /. If so, divide X and Y and output it. else...# +1l1-9-9-9-9-1isr1-1l1ie+9+9+9+9+1r1isl3mconr3-1ie #Checks if operation is %. If so, take remainder of X / Y and output it.#
Without comments
dsdcws-1wedepCpaplpcpuplpaptpopr+5+5oc-5-5pXp:p gnonl1+5+5oc-5-5r1r1pYp:p gnonl2+5+5oc-5-5r2r1pOppp:p gcocr1+5+5oc-5-5l1r1+1l1-9-9-9-9-7isr1-1l1ie+9+9+9+9+7r1isl3+conr3-1ie+1l1-9-9-9-9-9isr1-1l1ie+9+9+9+9+9r1isl3-conr3-1ie+1l1-9-9-9-9-6isr1-1l1ie+9+9+9+9+6r1isl3*conr3-1ie+1l1-9-9-9-9-9-2isr1-1l1ie+9+9+9+9+9+2r1isl3/conr3-1ie+1l1-9-9-9-9-1isr1-1l1ie+9+9+9+9+1r1isl3mconr3-1ie
To make it 16-bit, just write "16" at the start.
Even shorter
pCpaplpcpuplpaptpopr+5+5oc-5-5pXp:p gnonl1+5+5oc-5-5r1r1pYp:p gnonl2+5+5oc-5-5r2r1pOppp:p gcocr1+5+5oc-5-5l1-9-9-9-9-7izl2+conr2ix-2izl2-conr2ix+3izl2*conr2ix-5izl2/conr2ix+5+5izl2mconr2ix
A lot shorter
<<Calculator>>+5+5oc-5-5<<X: >>gnonl1+5+5ocr2<<Y: >>gnonl2ocr3<<Op: >>gcocl3ocr4s+l1-cizl2+conr2ix-2izl2-conr2ix+3izl2*conr2ix-5izl2/conr2ix+5+5izl2mconr2ix
GuLang
`0:G":u":L": ":C":a":l":c":u":l":a":t":o":r" `05`12`2*01" `05`12`2*01" `0:1":+": ":2":-": ":3":*": ":4":/"`05`12`2*01" `9[`0:n":u":m"::": "`1#`0:n":u":m"::": "`2#`3+12'`05`12`2*01"!] `8[`0:n":u":m"::": "`1#`0:n":u":m"::": "`2#`3-12'`05`12`2*01"!] `7[`0:n":u":m"::": "`1#`0:n":u":m"::": "`2#`3*12'`05`12`2*01"!] `6[`0:n":u":m"::": "`1#`0:n":u":m"::": "`2#`3/12'`05`12`2*01"!] `0#`11`0-01|9 -01|8 -01|7 -01|6 `0:e":r":r"`05`12`2*01"!
gur yvsr
IUIUIU `get the first value, second value, and operator (1: addition, 2: subtraction, 3: multiplication, 4: division, 5: modulus)` #1U#3k=a `check if operator is addition` C#3k#2U#3k=a `check if operator is subtraction` C#3k#3U#3k=a `check if operator is multiplication` C#3k#4U#3k=a `check if operator is division` C#3k#5U#3k=a `check if operator is modulus` . @C#1k%U#2-Ki. `modulus` @C#1k/U#2-Ki. `division` @C#1k*U#2-Ki. `multiplication` @C#1kR-F_UF#1k+U#2-Ki. `gur yvsr does not have a basic subtraction operation, so subtraction is more complicated` @C#1k+U#2-Ki. `addition`
Imperator
!!! CALCULATOR <ENTER FIRST NUMBER:> P V FNUMBER = I : FLOAT <ENTER SECOND NUMBER:> P V SNUMBER = I : FLOAT <RESULT:> P V RESULT = M FNUMBER + SNUMBER <> + FNUMBER + < + > + SNUMBER + < = > + RESULT P NEW RESULT = M FNUMBER - SNUMBER <> + FNUMBER + < - > + SNUMBER + < = > + RESULT P NEW RESULT = M FNUMBER * SNUMBER <> + FNUMBER + < * > + SNUMBER + < = > + RESULT P NEW RESULT = M FNUMBER / SNUMBER <> + FNUMBER + < / > + SNUMBER + < = > + RESULT P
JSInstruction
define instructions.js input x input operation input y math x operation y print x
instructions.js:
function input(variable) {
program.set(variable, program.input())
}
function math(x, op, y) {
var left = program.get(x)
var right = program.get(y)
if (op == "+") program.set(x, left + right)
if (op == "-") program.set(x, left - right)
if (op == "*") program.set(x, left * right)
if (op == "/") program.set(x, left / right)
if (op == "%") program.set(x, left % right)
}
function print(value) {
program.print("" + program.get(value))
}
Kas
va a = r(). va b = r(). va op = r(). >> op == 1. w(a+b). br(). <<. >> op == 2. w(a-b). br(). <<. >> op == 3. w(a*b). br(). <<. >> op == 4. w(a/b). br(). <<.
𝕃𝔸𝕄𝔹𝔻𝔸♯
λ 1 2 3 { - 2 - 0 3 } λ -1 2 3 { - 2 3 } input input input
Langlang
ask for an equation and calculate the answer and print it to the console.
LLvlN-FLOAT
RECIPE # Simple floating-point calculator TASTE SALT FLOAT # Read first number TASTE PEPPER FLOAT # Read second number # Addition BLEND GARLIC SALT FADD GARLIC PEPPER SERVE GARLIC FLOAT # Subtraction BLEND GARLIC SALT FSUB GARLIC PEPPER SERVE GARLIC FLOAT # Multiplication BLEND GARLIC SALT FMUL GARLIC PEPPER SERVE GARLIC FLOAT # Division BLEND GARLIC SALT FDIV GARLIC PEPPER SERVE GARLIC FLOAT DONE
Mash
- -Loops the program forever
$Calculator; -Prints Calculator to the screen
_Input {
+_^
_Input2 -Gathers input
+_^ -Also creates vars: Input, Input2, and Operation
_Operation
+_^ }
_Output -creates a variable named Output, pretty sure you can infer what that does
+_0 -Assgins zero to Output
=Operation,1 -Checks if Operation is 1(Addition)
*m+Input,Input2,Output -If it is true, add Input1 and Input2
*%Output -Prints Output
=Operation,2 {
*m-Input,Input2,Output
*%Output
=Operation,3
*mxInput,Input2,Output -Does same thing for Subtraction, Multiplication, and Division
*%Output
=Operation,4
*m/Input,Input2,Output
*%Output }
#Input {
#Input2 -Deletes variables so it can be repeated forever
#Operation
#Output }
Mezzo
in 0 1 nin(1-1) nin(1) 1-sign abs(0-'+') 1-sign abs(0-'-') 1-sign abs(0-'*') (1-sign abs(0-'/')) * sign abs(3) #2 $0 #3 $'=' #(2+3)*4+(2-3)*5+(2*3)*6+(2/(3-(3+1)*(1-7)))*7 $10010-10000 0/(0-0)
MultiStacker
pushs Input Number A: pushs Input Number B: pushs Input Operation: revs inputf inputf revf inputs opf revb cloneb if_strf not if_strb pushs The result was pushi 2 merge prints
NDBall
Nevermind
input,a: make,a,$answer input,b: make,b,$answer input,operation: make,operation,$answer if,$operation,==,+ make,final,$a,+,$b print,$final endif if,$operation,==,- make,final,$a,-,$b print,$final endif if,$operation,==,* make,final,$a,*,$b print,$final endif if,$operation,==,/ make,final,$a,/,$b print,$final endif
Oş Nõs
1 Repeat 2 Did you know "a" is "What's the first number"?? 3 /w wow! I didn't know that tell me another fact! 4 Did you know "b" is "What's the second number"?? 5 /w wow! I didn't know that tell me another fact! 6 Did you know "c" is "What's the operation"?? 7 /w wow I didn't know, but 8 What is a c b? 9 Hey, can you repeat that please? * 65535
Oxon
[First number of input]
[Second number of input]
[Operation to perform]
[Number used for multiplying]
W(I)(1)
W(I)(2)
W(I)(3)
F(*3*)("+")(12)
F(*3*)("*")(14)
F(*3*)("-")(20)
E
PA(*1*)(*2*)
E
WA(*2*)(*4*)(4)
WS(*1*)(1)(1)
F*1*(0)(18)
F(1)(1)(14)
P*4*
E
PS(*1*)(*2*)
E
Playerlang
take a operator as a number(1=+,2=-,3=*,4=/)
>"+ = 1, - = 2, * = 3, / = 4"sl;s"pleas Enter two more numbers"sldCa o Ca o Ca o Ca "Invalid"sx =============================================================================================== plus= es:w0w " = rewsnA" ;w;<<<< ================================================================#### minus= es:w1w " = rewsnA" ;w;<<<< =====================================================================#### multeply= es:w2w " = rewsnA" ;w;<<<< ==========================================================================#### Devide= es:w3w " = rewsnA" ;w;<<<< ================================================================================####
PriLogic
:Z:Z:Z:A"OPERATOR":A"A":A
"B":T"|OPERATOR|=`1`",[:X
"{{|A|/`10`}-`1`}+{{|B|/`
10`}-`1`}"]:T"|OPERATOR|=
`2`",[:X"{{|A|/`10`}-`1`}
-{{|B|/`10`}-`1`}"]:T"|OP
ERATOR|=`3`",[:X"{{|A|/`1
0`}-`1`}*{{|B|/`10`}-`1`}
"]:T"|OPERATOR|=`4`",[:X"
{{|A|/`10`}-`1`}/{{|B|/`1
0`}-`1`}"]:V"{|:#.:[[$%@"
Purl
CO EOR
MB EOR TYW
CO EOR TYW
P2 K1 P1 K1 P1 K2 DEC EOR
REP
CONT
P2 K1 P1 K2 P1 K1 DEC EOR
REP
CONT
P2 K1 P1 K1 P1 K1 P1 DEC EOR
REP
CONT
P2 K1 P1 K4 DEC EOR
REP
BO
CONT CONT
BEG YO EOR
SL BO
CONT CONT
BEG JOIN EOR
SL BO
CONT CONT
BEG DEC EOR
SL BO
CONT CONT
BEG INC EOR
SL
Quil
? numOne=
? numTwo=
? op=
10 LF=
op 1 [
numTwo 0 {
numOne + numOne=
numTwo - numTwo=
}
] op 2 [
numTwo 0 {
numOne - numOne=
numTwo - numTwo=
}
] op 3 [
numOne K=
numTwo- numTwo=
numTwo 0 {
K i=
i 0 {
numOne+ numOne=
i- i=
}
numTwo- numTwo=
}
] op 4 [
numTwo K=
0 c=
numOne numTwo [
0 numOne=
]
numOne 0 {
c+ c=
K i=
i 0 {
numOne - numOne=
i - i=
}
}
c+ numOne=
]
numOne%LF!
ReadWrite
1 WRITE 2 READ -1 WRITE 0 READ -1 WRITE 1 READ -1 # - 2 WRITE -2 READ -2 WRITE -3 13 WRITE -3 33 # - 2 WRITE -2 READ -2 WRITE -3 18 WRITE -3 35 # - 2 WRITE -2 READ -2 WRITE -3 23 WRITE -3 37 # - 2 WRITE -2 READ -2 WRITE -3 28 WRITE -3 39 # - 2 WRITE -2 READ -2 WRITE -3 42 WRITE -3 41 0 + 1 WRITE -3 42 0 - 1 WRITE -3 42 0 * 1 WRITE -3 42 0 / 1 WRITE -3 42 0 % 1 WRITE -1
S*n
|<S*n/i1><S*n/i2><S*n/o>_
{[[S*n/o]]="x"}(<S*n/o>[[[S*n/i1]]*[[S*n/i2]]]
[[:S*n/o]]){[[S*n/o]]="/"}
(<S*n/o>[[[S*n/i1]]/[[S*n/i2]]]
[[:S*n/o]]){[[S*n/o]]="+"}
(<S*n/o>[[[S*n/i1]]+[[S*n/i2]]]
[[:S*n/o]]){[[S*n/o]]="-"}
(<S*n/o>[[[S*n/i1]]-[[S*n/i2]]]
[[:S*n/o]])
SCiPL
play = true
function add()
a = stoi(input("Number A > "))
b = stoi(input("Number B > "))
print(NULL, "The result of A + B is:", a + b)
end
function multiply()
a = stoi(input("Number A > "))
b = stoi(input("Number B > "))
print(NULL, "The result of A * B is:", a * b)
end
function sub()
a = stoi(input("Number A > "))
b = stoi(input("Number B > "))
print(NULL, "The result of A - B is:", a - b)
end
function get_input(a)
print(NULL, [[
[A]dd
[M]ultiply
[S]ub
[Q]uit
]])
test = input(" > ")
test = string.upper(string.subscript(test, 0, 1))
if (test == "A") then
return add()
end
if (test == "M") then
return multiply()
end
if (test == "S") then
return sub()
end
if (test == "Q") then
play = false
end
end
print(NULL, "Welcome to the Calculator:")
while play do
get_input()
end
SDAPL
# Calculator get int get int get ascii ( plus pop pop add introduce # ) ( minus pop pop sub introduce # ) ( multiply pop pop mul introduce # ) ( divide pop pop div introduce # ) ( modulo pop pop mod introduce # ) ( end stop ) ( print pop introduce run loop ) ( loop length notempty print end ) ( error pop pop pop pop asciify Sorry, operation doesn't exist run loop ) ( check5 pop welcome % if 0 equals 1 modulo error ) ( check4 pop welcome / if 0 equals 1 divide check5 ) ( check3 pop welcome * if 0 equals 1 multiply check4 ) ( check2 pop welcome - if 0 equals 1 minus check3 ) welcome + if 0 equals 1 plus check2
SDOTOS
h[add_numbers]u~a!g h[subtract_numbers]u~ n1m Eg h[multiply_numbers]u~tg h[divide_numbers]u~g h[modulo_numbers]u~%g u:+pt[add_numbers]! u:-pt[subtract_numbers]a! u:*pt[multiply_numbers]pa! u:/pt[divide_numbers]pa! u:%pt[modulo_numbers]!
ShortO
Calculator: Enter number 1: $:; Enter number 2: $:; Enter operator: (+-*/%): $_ 2^ "+"=3>X+#out; 2^ "-"=3>X-#out; 2^ "/"=3>X/#out; 2^ "*"=3>X*#out; 2^ "%"=3>X%#out;; Invalid Operator! $#end;; #out; $,; #end;
Somp
(number\nnumber\nop\n)
N$"N$OP^10.;O:°",^43-+|!E!;-+;E:++^;N:,:,|^10-+!@^48-+/:$^1-&@ :~|^1+!;~0+/P::|?^1-+!p&@::=!@%~/ :&^1-&@::|^1+!;^48+./ p:^45.-;
Sonjalang
(Declare as floats, just in case.) telo Wan li sin. telo Tu li sin. (String to store the operator.) nimi Pali li sin.
o toki e ni: "First number? ". jan kepeken li pana sona pi telo Wan. o toki e ni: "Operator (+-*/%)? ". jan kepeken li pana sona pi nimi Pali. o toki e ni: "Second number? ". jan kepeken li pana sona pi telo Tu.
(If-else chain depending on the operator.)
"+" li sama nimi Pali anu seme? lon la:
o toki e ni: telo Wan en telo Tu.
ante la,
"-" li sama nimi Pali anu seme? lon la:
o toki e ni: telo Wan weka telo Tu.
ante la,
"*" li sama nimi Pali anu seme? lon la:
o toki e ni: telo Wan kulupu telo Tu.
ante la,
"/" li sama nimi Pali anu seme? lon la:
(A division by zero may cause an Arithmetic Error.)
o toki e ni: telo Wan kipisi telo Tu.
ante la,
"%" li sama nimi Pali anu seme? lon la:
(A division by zero may cause an Arithmetic Error.)
o toki e ni: telo Wan sike telo Tu.
ante la:
o toki e ni: "Invalid operator.".
SpellCast
shout the many cries of "Enter in first number: "
shout the many cries of
get the character from the spell 10
create a new spell named first with the power of
find the source of the messages
shout the many cries of "Enter in second number: "
shout the many cries of
get the character from the spell 10
create a new spell named second with the power of
find the source of the messages
shout the many cries of "Enter in operator (+ - * /): "
shout the many cries of
get the character from the spell 10
create a new spell named op with the power of
find the source of the messages
cast only if the spell is op equal to "+" is true do
shout the many cries of
combine the power of first and second
else do
cast only if the spell is op equal to "-" is true do
shout the many cries of
remove the power of second from first
else do
cast only if the spell is op equal to "*" is true do
shout the many cries of
duplicate the power of first second times
else do
cast only if the spell is op equal to "/" is true do
shout the many cries of
split the power of first second times
else do
shout the many cries of "Invalid Operator!"
done
done
done
done
StupidStackLanguage
hhhtdtdtblpxzubmxzublcxzubgxz
TextGarbage
i1ioi2mac7mc6maaac1msc9mc5mmc7mc6mdc7mc7mddsc2mrc5mc7mrrac2coeam11a2ecoesm11s2ecoemm11m2ecoedm11d2ecoerm11r2en1
Timers
(&&&\?."~)
Transposed
Input order is: op, first #, second #
01 0E 00 00 00 00 07 60 75 12 0F 03 68 07 90 55 02 0F 03 78 07 60 85 13 0F 03 88 07 60 75 02 0F 03 98 00 01 01 00 00 00 02 09 01 01 00 00 00 03 09 01 01 10 10 10 14 09 01 01 10 10 10 15 09
Tri-Tru-Eso
RED NUM AAA FST SPC RED NUM BBB SND SPC RED NUM OPP OPR SPC VAR NUM DEG ONE JPP ZZA OPP ADD AAA BBB OUT VAR AAA JPT BTM FLG ZZA SUB OPP DEG JPP ZZB OPP SUB AAA BBB OUT VAR AAA JPT BTM FLG ZZB SUB OPP DEG JPP ZZC OPP MUL AAA BBB OUT VAR AAA JPT BTM FLG ZZC SUB OPP DEG JPP ZZD OPP DIV AAA BBB OUT VAR AAA JPT BTM FLG ZZD SUB OPP DEG JPP ZZE OPP MOD AAA BBB OUT VAR AAA JPT BTM FLG ZZE OUT TXT ERR FLG BTM OUT TXT NWL END
VFUSL
|First Number: | print
num1 @in define
|Second Number: | print
num2 @in define
|Operator (+ - * /): | print
op @in define
result 0 define
op |+| ==
[
|result| num1 num2 + define
] [
op |-| ==
[
|result| num1 num2 - define
] [
op |*| ==
[
|result| num1 num2 * define
] [
op |/| ==
[
|result| num1 num2 / define
] [
|Not supported| print
] <--?
] <--?
] <--?
] <--?
result print
WaidWmy
I AM GOING TO SAY "ENTER A NUMBER" BECAUSE I CAN GET THE USERS INPUT LETS MAKE A VARIABLE NAMED FIRSTNUM WITH THE VALUE OF USERINPUT I AM GOING TO SAY "ENTER ANOTHER NUMBER" BECAUSE I CAN GET THE USERS INPUT LETS MAKE A VARIABLE NAMED SECONDNUM WITH THE VALUE OF USERINPUT I AM GOING TO SAY "ENTER IN AN OPERATOR" BECAUSE I CAN GET THE USERS INPUT LETS MAKE A VARIABLE NAMED OPERATOR WITH THE VALUE OF USERINPUT IF OPERATOR IS EQUAL TO "+" THEN LETS TALK ABOUT ADD IF OPERATOR IS EQUAL TO "-" THEN LETS TALK ABOUT SUB IF OPERATOR IS EQUAL TO "*" THEN LETS TALK ABOUT MUL IF OPERATOR IS EQUAL TO "/" THEN LETS TALK ABOUT DIV I AM GOING TO SAY "INVALID OPERATOR" BECAUSE I CAN PLEASE HALT THIS PROGRAM MAY I TALK ABOUT ADD HERE LETS MAKE A VARIABLE NAMED RESULT WITH THE VALUE OF FIRSTNUM LETS SELECT THE VARIABLE CALLED RESULT CAN WE ADD SECONDNUM TO THE SELECTED VARIABLE I AM GOING TO SAY RESULT BECAUSE I CAN PLEASE HALT THIS PROGRAM MAY I TALK ABOUT SUB HERE LETS MAKE A VARIABLE NAMED RESULT WITH THE VALUE OF FIRSTNUM LETS SELECT THE VARIABLE CALLED RESULT CAN WE SUBTRACT SECONDNUM TO THE SELECTED VARIABLE I AM GOING TO SAY RESULT BECAUSE I CAN PLEASE HALT THIS PROGRAM MAY I TALK ABOUT MUL HERE LETS MAKE A VARIABLE NAMED RESULT WITH THE VALUE OF FIRSTNUM LETS SELECT THE VARIABLE CALLED RESULT CAN WE MULTIPLY SECONDNUM TO THE SELECTED VARIABLE I AM GOING TO SAY RESULT BECAUSE I CAN PLEASE HALT THIS PROGRAM MAY I TALK ABOUT DIV HERE LETS MAKE A VARIABLE NAMED RESULT WITH THE VALUE OF FIRSTNUM LETS SELECT THE VARIABLE CALLED RESULT CAN WE DIVIDE SECONDNUM TO THE SELECTED VARIABLE I AM GOING TO SAY RESULT BECAUSE I CAN PLEASE HALT THIS PROGRAM
Whenever
1 defer(true) 0; 2 defer(true) 0; 3 defer(true) 0; 4 1#read() - 1; 5 defer(4) 2#read() - 1; 6 defer(5) 3#read() - 1; 7 defer(N(2) != 43 || 6) print(N(1) + N(3)); 8 defer(N(2) != 45 || 6) print(N(1) - N(3)); 9 defer(N(2) != 42 || 6) print(N(1) * N(3)); 10 defer(N(2) != 47 || 6) print(N(1) / N(3)); 11 defer(N(2) != 37 || 6) print(N(1) % N(3));
Wudge
set prompt {give an equation like **+* or **-* and this will answer (up to 10000 - 1): }
ask prompt arab
if arab found [+] do 1
replace arab [+/] to arab
if arab found [-] do 11
replace arab [*-*/SmS] to arab
replace arab [*-/Shm] to arab
if arab found [-*] do 1
jump 17
replace arab [SmS/$-$] to arab
replace arab [Shm/*-] to arab
if arab found [$] do 2
replace arab [$/] to arab
jump 6
replace arab [-/] to arab
jump 5
set msg {Result:}
replace arab [**********/t],[tttttttttt/h],[hhhhhhhhhh/T],[*********/9],[********/8],[*******/7],[******/6],[*****/5],[****/4],[****/3],[**/2],[*/1],[ttttttttt/9],[tttttttt/8],[ttttttt/7],[tttttt/6],[ttttt/5],[tttt/4],[tttt/3],[tt/2],[t/1],[hhhhhhhhh/9],[hhhhhhhh/8],[hhhhhhh/7],[hhhhhh/6],[hhhhh/5],[hhhh/4],[hhhh/3],[hh/2],[h/1],[TTTTTTTTT/9],[TTTTTTTT/8],[TTTTTTT/7],[TTTTTT/6],[TTTTT/5],[TTTT/4],[TTTT/3],[TT/2],[T/1] to arab
print msg
print arab
ZYXBasic
inp01Enter an operation (+, -, *, /, %): ife01+ gto12 ife01- gto22 ife01* gto35 ife01/ gto47 ife01% gto65 inp02Enter first number: inp03Enter second number: cgv0402 cgv0403 prv02 prt+ prv03 prt= prv04 gto999 inp02Enter first number: inp03Enter second number: cgv0402 cng051 cng04-1 ivn0305 gto25 prv02 prt- prv03 prt= prv04 gto999 inp02Enter first number: inp03Enter second number: cgv0403 cng051 ivn0205 gto37 prv02 prt× prv03 prt= prv04 gto999 inp02Enter first number: inp03Enter second number: cng051 cng061 ive0305 cng041 ive0305 str050 ivn0206 gto49 prv02 prt÷ prv03 prt= prv04 prtr prv05 gto999 inp02Enter first number: inp03Enter second number: cng041 cng051 ive0304 str040 ivn0205 gto67 prv02 prt% prv03 prt= prv04