-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput02.go
More file actions
18 lines (12 loc) · 745 Bytes
/
input02.go
File metadata and controls
18 lines (12 loc) · 745 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/* Alta3 Research | RZFeeser
Reading multiple inputs in a single line with Scanf */
package main
import "fmt"
func main() {
var name string // define a string variable (for tracking user name)
var age int // define an int var (for tracking user age)
fmt.Print("Enter your name & age: ") // "fmt.Print" is not followed by a /n
fmt.Scanf("%s %d", &name, &age) // "fmt.Scanf" function reads a string and an integer to the two provided variables
fmt.Printf("%s is %d years old\n", name, age) // "fmt.Printf" allows us to "format" text
// push our captured data to standard out using "formatters"
}