Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

Level 6 lesson 6 go lang

package main
import "fmt"

func division(x int, y int) {
var result float64
if y != 0 {
result = float64(x) / float64(y)
fmt.Printf("The result for division of %d by %d is %.2f\n",x,y,result)
} else {
fmt.Printf("You cannot divide a number by 0")
}
}

func main() {
// call the function
division(12,4)
}

i am not able to submit the question
by

2 Answers

sumit37367
how i submit more than one problem in a day
sam5epi0l
Try this code

package main
import "fmt"

func division(x int, y int) {
var result float64
if y != 0 {
result = float64(x/y)
fmt.Printf("The result for division of %d by %d is %0.2f",x,y,result)
} else {
fmt.Printf("You cannot divide a number by 0")
}
}

func main() {
// call the function
division(12, 4)
}

Login / Signup to Answer the Question.