Arithmetic/Integer: Difference between revisions
→{{header|Go}}: task conformance
(Added DWScript) |
(→{{header|Go}}: task conformance) |
||
Line 744:
=={{header|Go}}==
<lang go>
import "fmt"
fmt.Printf("a+b = %d\n", a+b)▼
fmt.Printf("a-b = %d\n", a-b)▼
func main() {
fmt.Printf("a*b = %d\n", a*b)▼
var a, b int
fmt.Printf("a/b = %d\n", a/b) // truncates towards 0▼
fmt.Print("enter two integers: ")
fmt.Printf("a%%b = %d\n", a%b) // same sign as first operand▼
fmt.Scanln(&a, &b)
// no exponentiation operator
}</lang>
Example run:
<pre>
enter two integers: -5 3
-5 + 3 = -2
-5 - 3 = -8
-5 * 3 = -15
-5 / 3 = -1
-5 % 3 = -2
</pre>
=={{header|Groovy}}==
|