Here, We are going to write a program to calculate area of Rectangle and Square in go golang. Area of rectangle is multiplication of length and breadth i.e length * breadth whereas area of Square is square of length i.e length * length.
Algorithm:
- Get the length and breadth of rectangle
- Calculate the area of rectangle by multiplying length and breadth
- Calculate the area of square by squaring the length
Example with code:
package main
import "fmt"
func main(){
var length, breadth = 3, 4
var area int
area = length * breadth
fmt.Println("Area of Rectangle : ", area)
area = length * length
fmt.Print("Area of Square : ", area)
}
Output:
Area of Rectangle : 12
Area of Square : 9
To learn more about golang, Please refer given below link.
https://techieindoor.com/go-lang-tutorial/
References:
https://golang.org/doc/
https://golang.org/pkg/
My brother suggested I might like this blog. He was entirely right.
This post actually made my day. You cann’t imagine just how much time I
had spent for this info! Thanks!
Thanks for your feedback !!!
Right here is the perfect site for everyone who wants to find out
about this topic. You know so much its almost tough to argue with you (not that I really would want to…HaHa).
You definitely put a new spin on a subject that has been discussed for decades.
Great stuff, just wonderful!
Thanks for your feedback !!!