GoLang
xxxxxxxxxx
package main
import (
"fmt"
"math"
)
type geometry interface {
area() float64
perim() float64
}
type rect struct {
width, height float64
}
type circle struct {
radius float64
}
func (r rect) area() float64 {
return r.width * r.height
}
func (r rect) perim() float64 {
return 2*r.width + 2*r.height
}
func (c circle) area() float64 {
return math.Pi * c.radius * c.radius
}
func (c circle) perim() float64 {
return 2 * math.Pi * c.radius
}
func measure(g geometry) {
fmt.Println(g)
fmt.Println(g.area())
fmt.Println(g.perim())
}
func main() {
r := rect{width: 3, height: 4}
c := circle{radius: 5}
measure(r)
measure(c)
}
{3 4} 12 14 {5} 78.53981633974483 31.41592653589793
Linux - anc-api-tools انسٹال کرنے کا طریقہ
Linux - curvedns انسٹال کرنے کا طریقہ
Python - چیک کریں کہ نمبر مثبت، منفی یا 0 ہے۔
Linux - zenmap انسٹال کرنے کا طریقہ
C - ایک عدد میں ہندسوں کی تعداد شمار کریں۔
C++ - لیپ سال چیک کریں۔
JavaScript - چیک کریں کہ آیا کوئی سٹرنگ شروع ہوتا ہے اور کچھ حروف کے ساتھ ختم ہوتا ہے۔
C++ - چیک کریں کہ نمبر پرائم ہے یا نہیں۔
C - ڈائنامک میموری ایلوکیشن کا استعمال کرتے ہوئے سب سے بڑی تعداد تلاش کریں۔
Linux - xbitmaps انسٹال کرنے کا طریقہ
Kotlin - ایک عدد کو n اعشاریہ جگہوں تک گول کریں۔
Kotlin - ایک نمبر کو ریورس کریں۔
Linux - zstd انسٹال کرنے کا طریقہ
Linux - zfs-test انسٹال کرنے کا طریقہ
Java - ایک نمبر کو ریورس کریں۔
Kotlin - کسی نمبر کا فیکٹریل تلاش کریں۔
Linux - zita-ajbridge انسٹال کرنے کا طریقہ
Kotlin - قدرتی نمبروں کے مجموعہ کا حساب لگائیں۔
We have been online since 2021 and 1 millions of people around the globe have visited our website since then
More visitors every month