2018-11-15 16:37:09 +03:00
|
|
|
// Copyright © 2018 Inanc Gumus
|
|
|
|
// Learn Go Programming Course
|
|
|
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
|
|
|
//
|
2019-10-30 19:34:44 +03:00
|
|
|
// For more tutorials : https://learngoprogramming.com
|
|
|
|
// In-person training : https://www.linkedin.com/in/inancgumus/
|
|
|
|
// Follow me on twitter: https://twitter.com/inancgumus
|
2018-11-15 16:37:09 +03:00
|
|
|
|
2018-11-13 17:43:25 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "fmt"
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
var (
|
2021-05-01 13:21:55 +03:00
|
|
|
names [3]string // The names of your three best friends
|
2018-11-17 21:56:09 +03:00
|
|
|
distances [5]int // The distances to five different locations
|
|
|
|
data [5]byte // A data buffer with five bytes of capacity
|
|
|
|
ratios [1]float64 // Currency exchange ratios only for a single currency
|
|
|
|
alives [4]bool // Up/Down status of four different web servers
|
|
|
|
zero [0]byte // A byte array that doesn't occupy memory space
|
2018-11-13 17:43:25 +03:00
|
|
|
)
|
|
|
|
|
2018-11-17 21:56:09 +03:00
|
|
|
// 1. Declare and print the arrays with their types.
|
2018-11-13 17:43:25 +03:00
|
|
|
fmt.Printf("names : %#v\n", names)
|
|
|
|
fmt.Printf("distances: %#v\n", distances)
|
|
|
|
fmt.Printf("data : %#v\n", data)
|
|
|
|
fmt.Printf("ratios : %#v\n", ratios)
|
2018-11-17 21:56:09 +03:00
|
|
|
fmt.Printf("alives : %#v\n", alives)
|
2018-11-13 17:43:25 +03:00
|
|
|
fmt.Printf("zero : %#v\n", zero)
|
|
|
|
|
2018-11-17 21:56:09 +03:00
|
|
|
// 2. Print only the types of the same arrays.
|
|
|
|
fmt.Println()
|
2018-11-13 17:43:25 +03:00
|
|
|
fmt.Printf("names : %T\n", names)
|
|
|
|
fmt.Printf("distances: %T\n", distances)
|
|
|
|
fmt.Printf("data : %T\n", data)
|
|
|
|
fmt.Printf("ratios : %T\n", ratios)
|
2018-11-17 21:56:09 +03:00
|
|
|
fmt.Printf("alives : %T\n", alives)
|
2018-11-13 17:43:25 +03:00
|
|
|
fmt.Printf("zero : %T\n", zero)
|
2018-11-17 21:56:09 +03:00
|
|
|
|
|
|
|
// 3. Print only the elements of the same arrays.
|
|
|
|
fmt.Println()
|
|
|
|
fmt.Printf("names : %q\n", names)
|
|
|
|
fmt.Printf("distances: %d\n", distances)
|
|
|
|
fmt.Printf("data : %d\n", data)
|
|
|
|
fmt.Printf("ratios : %.2f\n", ratios)
|
|
|
|
fmt.Printf("alives : %t\n", alives)
|
|
|
|
fmt.Printf("zero : %d\n", zero)
|
2018-11-13 17:43:25 +03:00
|
|
|
}
|