push all exercices
This commit is contained in:
BIN
ch5/1/ch5_1.exe
Normal file
BIN
ch5/1/ch5_1.exe
Normal file
Binary file not shown.
20
ch5/1/ch5_1.go
Normal file
20
ch5/1/ch5_1.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func simpleCalculator(dividend, divisor int) (int, error) {
|
||||
if divisor == 0 {
|
||||
err := errors.New("division by zero")
|
||||
return 0, err
|
||||
}
|
||||
return dividend / divisor, nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
fmt.Println(simpleCalculator(5, 2))
|
||||
fmt.Println(simpleCalculator(5, 0))
|
||||
fmt.Println(simpleCalculator(17, 6))
|
||||
}
|
||||
3
ch5/1/go.mod
Normal file
3
ch5/1/go.mod
Normal file
@@ -0,0 +1,3 @@
|
||||
module ch5_1
|
||||
|
||||
go 1.25.0
|
||||
Reference in New Issue
Block a user