Skip to content

Latest commit

 

History

History
62 lines (43 loc) · 846 Bytes

exercise.md

File metadata and controls

62 lines (43 loc) · 846 Bytes

Data Types

Objectives

  1. What is the result of the following program? Why?
package main

import "fmt"

func main() {
    var userName
    userName = "user"
    fmt.Println(userName)
}
  1. What is the result of the following program? Why?
package main

import "fmt"

func main() {
    var userName = "user"
    fmt.Println(userName)
}
  1. Fix the following program by modifying one of the lines (but not adding or removing lines)
package main

import "fmt"

func main() {
    var userName
    userName = "user"
    fmt.Println(userName)
}
  1. Modify the following program to print the types of the variables
package main

import "fmt"

func main() {
    var food = "Pizza"
    var slices = 4
    var pineappleOnPizza = true
}

Solution

Click here to view the solution