1. Variables and Operators
Activity 1.01 Defining and Printing
Solution:
- Define the package name:
package main
- Import the required packages:
import "fmt"
- Create a
main()
function:func main() {
- Declare and initialize a string variable for the given name:
firstName := "Bob"
- Declare and initialize a string variable for the family name:
familyName := "Smith"
- Declare and initialize an
int
variable forage
:age := 34
- Declare and initialize a
bool
variable forpeanutAllergy
:peanutAllergy := false
- Print each variable to the console:
fmt.Println(firstName) fmt.Println(familyName) fmt.Println(age) fmt.Println(pean utAllergy)
- Close the
main()
function:}
The following is the expected output:
Activity 1.02: Pointer Value Swap
Solution:
-
...