Section11-2

This commit is contained in:
2023-11-15 15:18:17 +01:00
parent 110aab4934
commit 12c600ef09
3 changed files with 83 additions and 0 deletions

45
Section11/89-2.go Normal file
View 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)
}