add: printf exercises

This commit is contained in:
Inanc Gumus
2018-10-27 16:38:54 +03:00
parent 1a21064e7d
commit c37cf60701
21 changed files with 40 additions and 10 deletions

View File

@ -0,0 +1,25 @@
// 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
// ---------------------------------------------------------
// EXERCISE: Print Your Fullname
//
// 1. Get your name and lastname from the command-line
// 2. Print them using Printf
//
// EXAMPLE INPUT
// Inanc Gumus
//
// EXPECTED OUTPUT
// Your name is Inanc and your lastname is Gumus.
// ---------------------------------------------------------
func main() {
// BONUS: Use a variable for the format specifier
}

View File

@ -0,0 +1,23 @@
// 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() {
// WARNING: This program will error
// if you don't pass your name and lastname
name, lastname := os.Args[1], os.Args[2]
msg := "Your name is %s and your lastname is %s.\n"
fmt.Printf(msg, name, lastname)
}