Y
Y
Yuri2020-06-26 14:04:05
Unity
Yuri, 2020-06-26 14:04:05

How to correctly describe a method that finds the area of ​​a circle given a given radius?

Describe a method that calculates the area of ​​a circle given a given radius. Returns a fractional number.
I can't figure out how to properly describe this method, my code is below:

void Start()
 {
   float  circle =Mathf.PI;
   float R= 3;
   float result=GetSquareofcircle(R);
 Debug.Log(result);
 }
 float GetSquareofcircle(float R)
{
float circlesquare = Mathf.PI *Mathf.Pow(R,R);
 return(circlesquare);
}


I would be grateful if you help)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
yuopi, 2020-06-26
@uriy99

float circlesquare = Mathf.PI *Mathf.Pow(R, 2 );
But, for squaring it is better not to use Pow.
float circlesquare = Mathf.PI * R * R;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question