Lesson 3 of 15
Arithmetic
Arithmetic Operations
Perl supports the standard arithmetic operators:
| Operator | Meaning |
|---|---|
+ | Addition |
- | Subtraction |
* | Multiplication |
/ | Division |
% | Modulo |
** | Exponentiation |
my $sum = 10 + 3; # 13
my $diff = 10 - 3; # 7
my $prod = 10 * 3; # 30
my $quot = 10 / 3; # 3.33333...
my $mod = 10 % 3; # 1
my $pow = 2 ** 8; # 256
Compound Assignment
my $x = 10;
$x += 5; # $x is now 15
$x -= 3; # $x is now 12
$x *= 2; # $x is now 24
Your Task
Calculate 2 ** 10 (two to the power of ten) and print the result.
JS Transpiler loading...
Loading...
Click "Run" to execute your code.