Go practice problem | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Go practice problem

The given code declares a Timer struct, which is initialized in main(). You need to add a reset functionality to the program. The reset() function needs to take a pointer to the struct as its argument and reset the seconds value to 0.

23rd Jul 2021, 9:31 AM
Chinmay Anand
Chinmay Anand - avatar
2 Answers
0
package main import "fmt" type Timer struct { id string seconds int } func main() { var x int fmt.Scanln(&x) t :=&Timer{"ABC", x} func reset("ABC",0) fmt.Println(t) }
23rd Jul 2021, 10:31 AM
Chinmay Anand
Chinmay Anand - avatar
0
Expected out is (ABC 0)
23rd Jul 2021, 11:05 AM
Chinmay Anand
Chinmay Anand - avatar