B
This commit is contained in:
parent
e5e8880e41
commit
518da4a923
1019 changed files with 15877 additions and 0 deletions
|
|
@ -0,0 +1,9 @@
|
|||
input "enter a number ?", a
|
||||
input "enter another number ?", b
|
||||
|
||||
print "addition " + a + " + " + b + " = " + (a + b)
|
||||
print "subtraction " + a + " - " + b + " = " + (a - b)
|
||||
print "multiplication " + a + " * " + b + " = " + (a * b)
|
||||
print "integer division " + a + " \ " + b + " = " + (a \ b)
|
||||
print "remainder or modulo " + a + " % " + b + " = " + (a % b)
|
||||
print "power " + a + " ^ " + b + " = " + (a ^ b)
|
||||
9
Task/Arithmetic-Integer/BBC-BASIC/arithmetic-integer.bbc
Normal file
9
Task/Arithmetic-Integer/BBC-BASIC/arithmetic-integer.bbc
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
INPUT "Enter the first integer: " first%
|
||||
INPUT "Enter the second integer: " second%
|
||||
|
||||
PRINT "The sum is " ; first% + second%
|
||||
PRINT "The difference is " ; first% - second%
|
||||
PRINT "The product is " ; first% * second%
|
||||
PRINT "The integer quotient is " ; first% DIV second% " (rounds towards 0)"
|
||||
PRINT "The remainder is " ; first% MOD second% " (sign matches first operand)"
|
||||
PRINT "The first raised to the power of the second is " ; first% ^ second%
|
||||
13
Task/Arithmetic-Integer/Batch-File/arithmetic-integer.bat
Normal file
13
Task/Arithmetic-Integer/Batch-File/arithmetic-integer.bat
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
@echo off
|
||||
set /P A=Enter 1st Number :
|
||||
set /P B=Enter 2nd Number :
|
||||
set D=%A% + %B% & call :printC
|
||||
set D=%A% - %B% & call :printC
|
||||
set D=%A% * %B% & call :printC
|
||||
set D=%A% / %B% & call :printC & rem truncates toward 0
|
||||
set D=%A% %% %B% & call :printC & rem matches sign of 1st operand
|
||||
exit /b
|
||||
|
||||
:printC
|
||||
set /A C=%D%
|
||||
echo %D% = %C%
|
||||
7
Task/Arithmetic-Integer/Brat/arithmetic-integer.brat
Normal file
7
Task/Arithmetic-Integer/Brat/arithmetic-integer.brat
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
x = ask("First number: ").to_i
|
||||
y = ask("Second number: ").to_i
|
||||
|
||||
#Division uses floating point
|
||||
#Remainder uses sign of right hand side
|
||||
[:+ :- :* :/ :% :^].each { op |
|
||||
p "#{x} #{op} #{y} = #{x.call_method op, y}"
|
||||
Loading…
Add table
Add a link
Reference in a new issue