Question: I am finding it hard to debug this line of code. The proper result should be 14,130 but I am getting 10597.5 instead when the input is 15 for area of a sphere. Below is the code:

```
// HW1, Q2
#include <iostream>
using namespace std;
int main() {

    // declare variables for radius, length and formulas.

    int user_nbr;
    double pi, sqr_area, circ_area, sphr_area;
    pi = 3.14;

    cout<<"Hi, enter an integer: "<<endl;

    // write in user data into declared variables
    cin >> user_nbr, sqr_len, circ_rad, sphr_rad;
    sqr_area = user_nbr * user_nbr;
    circ_area = pi * user_nbr * user_nbr;
    sphr_area = (4/3) * pi * user_nbr * user_nbr * user_nbr;

    // displays answers to user
    cout<<"\nThe area of a square with length "
        <<user_nbr<<" is "<<sqr_area<<". The area "
        <<"of a circle with radius "<<user_nbr
        <<" is "<<circ_area<<". Lastly, the area "
        <<"of a sphere with radius "<<user_nbr
        <<" is "<<sphr_area<<".";

return 0;
}

```

I am new to C++ so I am attempting to understand the operators and their workings. I know it's () \*/% +- in that order of precedence.

Answer: 
The result of `4/3` is an `int`, so it's `1`, use:

```
sphr_area = (4.0/3.0) * pi * user_nbr * user_nbr * user_nbr;

```

**[6.5.5 Multiplicative operators 6](https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&uact=8&ved=2ahUKEwio_PLlpsPnAhVrA2MBHYklAkwQFjABegQIBBAB&url=https%3A%2F%2Fwww.chiefdelphi.com%2Fuploads%2Fdefault%2Foriginal%2F3X%2Fe%2Fa%2Fea06bab93c007a2ef8342874a5e7ccac9d535d06.pdf&usg=AOvVaw03aB6i2-zHip7n3N2TxOk3)**

> 
> When integers are divided, the result of the `/` operator is the algebraic quotient with any fractional part discarded. If the quotient `a/b` is representable, the expression `(a/b)*b + a%b` shall equal `a`.
> 
> 
> 
> 
> ---
> 
> 
> Note: This is often called ‘‘truncation toward zero’’.
> 
> 
> 

**ISO/IEC 9899:TC3**
Is this what you expect?

```
[cling]$ double sphr_area = 4/3;
[cling]$ sphr_area
(double) 1.0000000

```

Otherwise it is misuse of types, and not an order of operations issue.

Also for π you would want to use the `math.h` constants, if available (see <https://stackoverflow.com/a/1727896>)