I'm doing an exercise which needs to find a percentage of something...
In the code below, when I initialise x with 100.0 / 8.0 it the output is correct, however. If I write x = 100 / 8 it says 10.64. I know its something to do with the values written as integers but what is the computer actually doing here?
Many thanks
Code:int main() { //double input; double price = 128.0; double x; x = 100.0 / 8.0; price/= x; cout << "Price with 8% discount: " << price << endl; return 0; }