Skip to content

Commit d553c0c

Browse files
Merge pull request #61 from trojan0x/patch-1
create inputs.go
2 parents 9956909 + 809b927 commit d553c0c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

beginner/inputs.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// This is a simple program that shows how to use go in taking inputs from a console... It takes in name and age as inputs and then uses conditionals to see if the age is permitted to continue
2+
package main
3+
4+
import "fmt"
5+
6+
func main() {
7+
fmt.Printf("What's your name? : ")
8+
var name string
9+
fmt.Scanln(&name)
10+
fmt.Printf("How old are you? : ")
11+
var age int
12+
fmt.Scanln(&age)
13+
if age < 18 {
14+
fmt.Println(name, "You are too young to continue! ")
15+
16+
} else {
17+
fmt.Println("Nice to see you", name)
18+
}
19+
}

0 commit comments

Comments
 (0)