add: numbers and strings exercises
This commit is contained in:
@ -0,0 +1,45 @@
|
||||
// For more tutorials: https://blog.learngoprogramming.com
|
||||
//
|
||||
// Copyright © 2018 Inanc Gumus
|
||||
// Learn Go Programming Course
|
||||
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||
//
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// EXERCISE: Raw Concat
|
||||
//
|
||||
// 1. Initialize the name variable
|
||||
// by getting input from the command line
|
||||
//
|
||||
// 2. Use concatenation operator to concatenate it
|
||||
// with the raw string literal below
|
||||
//
|
||||
// NOTE
|
||||
// You should concatenate the name variable in the correct
|
||||
// place.
|
||||
//
|
||||
// EXPECTED OUTPUT
|
||||
// Let's say that you run the program like this:
|
||||
// go run main.go inanç
|
||||
//
|
||||
// Then it should output this:
|
||||
// hi inanç!
|
||||
// how are you?
|
||||
// ---------------------------------------------------------
|
||||
|
||||
func main() {
|
||||
// uncomment the code below
|
||||
// name := "and get the name from the command-line"
|
||||
|
||||
// replace and concatenate the `name` variable
|
||||
// after `hi ` below
|
||||
|
||||
msg := `hi CONCATENATE-NAME-VARIABLE-HERE!
|
||||
how are you?`
|
||||
|
||||
fmt.Println(msg)
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
// For more tutorials: https://blog.learngoprogramming.com
|
||||
//
|
||||
// Copyright © 2018 Inanc Gumus
|
||||
// Learn Go Programming Course
|
||||
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
||||
//
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
name := os.Args[1]
|
||||
|
||||
msg := `hi ` + name + `!
|
||||
how are you?`
|
||||
|
||||
fmt.Println(msg)
|
||||
}
|
Reference in New Issue
Block a user