fix: exercises for write your first library and variables find the rectangle area exercise
This commit is contained in:
@ -10,13 +10,13 @@ package main
|
||||
// ---------------------------------------------------------
|
||||
// EXERCISE: Find the Rectangle's Area
|
||||
//
|
||||
// 1. Find the length of a rectangle
|
||||
// 1. Find the area of a rectangle
|
||||
// Its width is 5
|
||||
// Its height is 6
|
||||
//
|
||||
// 2. Assign the result to the `length` variable
|
||||
// 2. Assign the result to the `area` variable
|
||||
//
|
||||
// 3. Print the `length` variable
|
||||
// 3. Print the `area` variable
|
||||
//
|
||||
// HINT
|
||||
// Rectangle formula = 2 * (width + height)
|
||||
@ -29,7 +29,7 @@ func main() {
|
||||
// UNCOMMENT THE CODE BELOW:
|
||||
|
||||
// var (
|
||||
// length int
|
||||
// area int
|
||||
// width, height = 5, 6
|
||||
// )
|
||||
|
||||
|
@ -11,7 +11,7 @@ import "fmt"
|
||||
|
||||
func main() {
|
||||
var (
|
||||
length int
|
||||
area int
|
||||
width, height = 5, 6
|
||||
)
|
||||
|
||||
@ -20,7 +20,7 @@ func main() {
|
||||
|
||||
// just like in math
|
||||
|
||||
length = 2 * (width + height)
|
||||
area = 2 * (width + height)
|
||||
|
||||
fmt.Println(length)
|
||||
fmt.Println(area)
|
||||
}
|
||||
|
Reference in New Issue
Block a user