function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
el hadji mory ndaw 6el hadji mory ndaw 6 

calculate square

Ramakrishna Reddy GouniRamakrishna Reddy Gouni
In apex 
Example: calculate a square.

Decimal a=4;
Math.pow(a, 2);

 
Ajay K DubediAjay K Dubedi
Hi El,

The question is quite simple. 
You can use Math.pow(number, power) method.

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com
Deepali KulshresthaDeepali Kulshrestha
Hi el,

I've gone through your requirement and you can find the apex code below:

Apex code:

public class square {

//method to calculate sqaureRoot
    public static void Squre(integer squareRoot)
    {
        System.debug(Math.sqrt(squareRoot));
    }
   
//method to calculate square 
    public static void SqRoot(integer square)
    {
        System.debug(Math.pow(square,2));
    }

}



I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com