Section11-2
This commit is contained in:
45
Section11/89-2.go
Normal file
45
Section11/89-2.go
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
Coding Exercise #2
|
||||
|
||||
There are some errors in the following Go program. Try to identify the errors,
|
||||
change the code and run the program without errors.
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
mySlice := []float64{1.2, 5.6}
|
||||
|
||||
mySlice[2] = 6
|
||||
|
||||
a := 10
|
||||
mySlice[0] = a
|
||||
|
||||
mySlice[3] = 10.10
|
||||
|
||||
mySlice = append(mySlice, a)
|
||||
|
||||
fmt.Println(mySlice)
|
||||
|
||||
}
|
||||
*/
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
mySlice := []float64{1.2, 5.6}
|
||||
|
||||
mySlice[1] = 6
|
||||
|
||||
a := 10
|
||||
mySlice[0] = float64(a)
|
||||
|
||||
mySlice[1] = 10.10
|
||||
|
||||
mySlice = append(mySlice, float64(a))
|
||||
|
||||
fmt.Println(mySlice)
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user