+ 1

You are building a Timer app that should count up to a given number. Your program needs to take a number as input and make the

Variable is not increament package main import "fmt" type Timer struct { id string value int } func (t Timer)tick (){ fmt.Println(t.value +1) t.value+=1 } func main() { var x int fmt.Scanln(&x) t := Timer{"timer1", 0} for i:=0;i<x;i++ { t.tick() } }

3rd Jul 2021, 3:31 AM
PRAKASH CHANDRA MOHAPATRA
PRAKASH CHANDRA MOHAPATRA - avatar
2 Antworten
+ 7
func (t *Timer) tick () { t.value++ fmt.Println(t.value) }
3rd Jul 2021, 4:06 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
You are building a Timer app that should count up to a given number Your program needs to take a number as input and make the Timer tick that number of times. The code in main initializes a Timer and takes a number as input Then it calls the tick() method for the Timer the given number of D times Define the Timer struct with two fields id and value, and define the tick() method, which should increment the value by one and output its current value
21st Jan 2023, 1:28 PM
ROHIT Kumar
ROHIT Kumar - avatar