Question: ```
int i = 5;
int j = 3;
int k;
double a, b;

k = j / 2 * i / 10;
a = 0.1 * i * j / 2.0;
b = 0.1 * (j / i) + 3.0;

```

So by doing it by hand one would get k=0.75, a=0.75, and b=3.06. Yet when I solve it in Visual Studio I get 0, 0.75, and 3.00. I was hoping someone could shed light on this. I know int means only whole values can be output but why is b = 3.00 rather than 3.06 since b is a double?

Answer: 
All of your variables should be `double` because if they are `int` integer operation will occur and your result will not contain decimal places.

```
double i = 5;
double j = 3;
double k;
double a, b;

k = j / 2 * i / 10;
a = 0.1 * i * j / 2.0;
b = 0.1 * (j / i) + 3.0;

```
In your code, 

* `i` and `j` are of type `int`
* the integer constants used here are also of type `int`,

So, in case of

```
k = j / 2 * i / 10;

```

integer division / multiplication will take place and the *final* result will be **promoted** to type `double`. This is not what you want.

either

* use `double` for `i` and `j`
* use casting to enforce floating point operation.

Same for the `(j / i)` part in below case.

```
b = 0.1 * (j / i) + 3.0;

```

OTOH, in case of

```
a = 0.1 * i * j / 2.0;

```

gives correct output, as the constant `0.1` or `2.0` denotes a `double` type, and because of the usual arithmetic conversion of the operands, floating point division / multiplication is performed.