# Whats wrong with my programm

+3 votes
asked Nov 26, 2020

I need to solve it,but the solution is -0.

## 1 Answer

+1 vote
answered Nov 27, 2020 by (10,520 points)
```V=((S/3)*sqrt(S/3.14)*pow(tan(3.14/4-L/2),-3)*pow(tan(L),-1));
```

Can you try the above,It displays non 0 output.

Also the formula u shared has  tan cubed, but in your code you have used cube root,I thinks its wrong.

I would suggest that you break the individual pow,tan functions & assign them to seperate variables & finally perform the calcualtion on these individual variables.There are associativitey & precedence rules for operators which I find it difficult to always keep them in mind.

eg

```double root_S_by_pi = sqrt(S/3.14);
double tanL_by_2= tan(3.14/4-L/2);
..
..
//finally
V=((S/3)*root_S_by_pi*pow(tanL_by_2,-3)*tan(L));
//V=((S/3)*sqrt(S/3.14)*pow(tan(3.14/4-L/2),-3)*pow(tan(L),-1)); //<--- original code

```

Also check the sample usage of tan() on this page: https://www.cplusplus.com/reference/cmath/tan/

Specifically note usage of tan :-->

```result = tan ( param * PI / 180.0 );

I think thats how the tan () should be invoked.
```