fix: rectangle's area -> perimeter
This commit is contained in:
@ -8,15 +8,15 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// EXERCISE: Find the Rectangle's Area
|
// EXERCISE: Find the Rectangle's Perimeter
|
||||||
//
|
//
|
||||||
// 1. Find the area of a rectangle
|
// 1. Find the perimeter of a rectangle
|
||||||
// Its width is 5
|
// Its width is 5
|
||||||
// Its height is 6
|
// Its height is 6
|
||||||
//
|
//
|
||||||
// 2. Assign the result to the `area` variable
|
// 2. Assign the result to the `perimeter` variable
|
||||||
//
|
//
|
||||||
// 3. Print the `area` variable
|
// 3. Print the `perimeter` variable
|
||||||
//
|
//
|
||||||
// HINT
|
// HINT
|
||||||
// Rectangle formula = 2 * (width + height)
|
// Rectangle formula = 2 * (width + height)
|
||||||
@ -29,7 +29,7 @@ func main() {
|
|||||||
// UNCOMMENT THE CODE BELOW:
|
// UNCOMMENT THE CODE BELOW:
|
||||||
|
|
||||||
// var (
|
// var (
|
||||||
// area int
|
// perimeter int
|
||||||
// width, height = 5, 6
|
// width, height = 5, 6
|
||||||
// )
|
// )
|
||||||
|
|
@ -11,7 +11,7 @@ import "fmt"
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var (
|
var (
|
||||||
area int
|
perimeter int
|
||||||
width, height = 5, 6
|
width, height = 5, 6
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ func main() {
|
|||||||
|
|
||||||
// just like in math
|
// just like in math
|
||||||
|
|
||||||
area = 2 * (width + height)
|
perimeter = 2 * (width + height)
|
||||||
|
|
||||||
fmt.Println(area)
|
fmt.Println(perimeter)
|
||||||
}
|
}
|
@ -10,7 +10,7 @@ Now, get your feet wet and try some assignment exercises.
|
|||||||
|
|
||||||
3. **[Assign With Expressions](https://github.com/inancgumus/learngo/tree/master/06-variables/04-assignment/exercises/03-assign-with-expressions)**
|
3. **[Assign With Expressions](https://github.com/inancgumus/learngo/tree/master/06-variables/04-assignment/exercises/03-assign-with-expressions)**
|
||||||
|
|
||||||
4. **[Find the Rectangle's Area](https://github.com/inancgumus/learngo/tree/master/06-variables/04-assignment/exercises/04-find-the-rectangle-area)**
|
4. **[Find the Rectangle's Perimeter](https://github.com/inancgumus/learngo/tree/master/06-variables/04-assignment/exercises/04-find-the-rectangle-perimeter)**
|
||||||
|
|
||||||
5. **[Multi Assign](https://github.com/inancgumus/learngo/tree/master/06-variables/04-assignment/exercises/05-multi-assign)**
|
5. **[Multi Assign](https://github.com/inancgumus/learngo/tree/master/06-variables/04-assignment/exercises/05-multi-assign)**
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user