Exponentiation with infix operators in (or operating on) the base: Difference between revisions
Content added Content deleted
(Add QB64) |
|||
Line 318: | Line 318: | ||
x = 5, p = 2, power(-x,p) = 25, -power(x,p) = -25 |
x = 5, p = 2, power(-x,p) = 25, -power(x,p) = -25 |
||
x = 5, p = 3, power(-x,p) = -125, -power(x,p) = -125 |
x = 5, p = 3, power(-x,p) = -125, -power(x,p) = -125 |
||
</pre> |
|||
=={{header|QB64}}== |
|||
<lang qb64>For x = -5 To 5 Step 10 |
|||
For p = 2 To 3 |
|||
Print "x = "; x; " p ="; p; " "; |
|||
Print Using "-x^p is ####"; -x ^ p; |
|||
Print Using ", -(x)^p is ####"; -(x) ^ p; |
|||
Print Using ", (-x)^p is ####"; (-x) ^ p; |
|||
Print Using ", -(x^p) is ####"; -(x ^ p) |
|||
Next |
|||
Next</lang> |
|||
{{out}} |
|||
<pre> |
|||
x = -5 p = 2 -x^p is -25, -(x)^p is -25, (-x)^p is 25, -(x^p) is -25 |
|||
x = -5 p = 3 -x^p is 125, -(x)^p is 125, (-x)^p is 125, -(x^p) is 125 |
|||
x = 5 p = 2 -x^p is -25, -(x)^p is -25, (-x)^p is 25, -(x^p) is -25 |
|||
x = 5 p = 3 -x^p is -125, -(x)^p is -125, (-x)^p is -125, -(x^p) is -125 |
|||
</pre> |
</pre> |
||