using % on a double in c++

c++, double, operators

Solution

You should use the `std::fmod()` function from the `<cmath>` Standard header:

#include <cmath>

// ...

double j = fmod(full_price_in_pence, 100);

Problem

im trying to use the % operator on a double in c++, i have done the same in java and it works fine. is there something im missing here or is this not allowed, sorry im new to c++ so might be making a really stupid error here ``` double i = full_price_in_pence / 100.0; double j = full_price_in_pence % 100; int final_pounds = (int) i; int final_pence = (int) j; ``` and these are both double values ``` full_price_in_pence full_price_in_pounds ```

Original source

Related problems