Arithmetic/Integer: Difference between revisions
Content added Content deleted
No edit summary |
(Added FreeBASIC) |
||
Line 1,177: | Line 1,177: | ||
PRINT *, ' A ** B = ', (A ** B) |
PRINT *, ' A ** B = ', (A ** B) |
||
END</lang> |
END</lang> |
||
=={{header|FreeBASIC}}== |
|||
<lang freebasic>' FB 1.05.0 Win64 |
|||
Dim As Integer i, j |
|||
Input "Enter two integers separated by a comma"; i, j |
|||
Print i;" + "; j; " = "; i + j |
|||
Print i;" - "; j; " = "; i - j |
|||
Print i;" * "; j; " = "; i * j |
|||
Print i;" / "; j; " = "; i \ j |
|||
Print i;" % "; j; " = "; i Mod j |
|||
Print i;" ^ "; j; " = "; i ^ j |
|||
Sleep |
|||
' Integer division (for which FB uses the '\' operator) rounds towards zero |
|||
' Remainder (for which FB uses the Mod operator) will, if non-zero, match the sign |
|||
' of the first operand</lang> |
|||
Sample input and output:- |
|||
{{out}} |
|||
<pre> |
|||
Enter two integers separated by a comma? -12, 7 |
|||
-12 + 7 = -5 |
|||
-12 - 7 = -19 |
|||
-12 * 7 = -84 |
|||
-12 / 7 = -1 |
|||
-12 % 7 = -5 |
|||
-12 ^ 7 = -35831808 |
|||
</pre> |
|||
=={{header|F_Sharp|F#}}== |
=={{header|F_Sharp|F#}}== |