Anuradh S - 1 year ago 93

Objective-C Question

I am asking for ways to calculate the square root of any given number in

`ios`

`Objective C`

`X = √5`

then

`log10X = log10(√5)`

this means

`log10X = log10(5)/2;`

then should get the value of

`log10(5)`

`divide`

`2`

`antilog`

`X`

`double getlogvalue = log10(5)/2; // in here the get the value of 5 in log10 and divide it from two.`

//then get the antilog value for the getlogvalue

double getangilogvalue = pow(10,getlogvalue);

//this will give the square root of any number. and the answer may include for few decimal points. so to print with two decimal point,

NSLog(@"square root of the given number is : %.02f", getantilogvalue);

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

The `sqrt`

function (and other mathematical functions as well) is
available in the standard libraries on all OS X and iOS platforms.

It can be used from (Objective-)C:

```
#include "math.h"
double sqrtFive = sqrt(5.0);
```

and from Swift:

```
import Darwin // or Foundation, Cocoa, UIKit, ...
let sqrtFive = sqrt(5.0)
```

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**