newGo
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
)
|
||||
|
||||
func main() {
|
||||
tries := 1
|
||||
randNum := rand.Intn(10) + 1 // Generate a number between 1 and 10
|
||||
|
||||
for tries <= 5 {
|
||||
var x int
|
||||
fmt.Print("Guess a Number between 1 and 10: ")
|
||||
fmt.Scan(&x)
|
||||
|
||||
if randNum == x {
|
||||
fmt.Println("That's great, you got the right number!")
|
||||
return
|
||||
} else {
|
||||
fmt.Println("Guess again")
|
||||
}
|
||||
tries++
|
||||
}
|
||||
|
||||
fmt.Printf("The right number was %d\n", randNum)
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
run:
|
||||
go run Guess.go
|
||||
@@ -0,0 +1,3 @@
|
||||
module gitea.zacksolutions.dev/Zakaria/LeanGo.git
|
||||
|
||||
go 1.22.7
|
||||
Reference in New Issue
Block a user