Section9-complete
This commit is contained in:
42
Section9/76-3.go
Normal file
42
Section9/76-3.go
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
Coding Exercise #3
|
||||
|
||||
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() {
|
||||
myArray := [3]float64{1.2, 5.6}
|
||||
|
||||
myArray[2] = 6
|
||||
|
||||
a := 10
|
||||
myArray[0] = a
|
||||
|
||||
myArray[3] = 10.10
|
||||
|
||||
fmt.Println(myArray)
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
myArray := [3]float64{1.2, 5.6}
|
||||
|
||||
myArray[2] = 6
|
||||
|
||||
a := 10
|
||||
myArray[0] = float64(a)
|
||||
|
||||
myArray[2] = 10.10
|
||||
|
||||
fmt.Println(myArray)
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user