0
Why does the following code only produce an integer?
Please review the below. I totally get that if x was declared as an INT then the answer should be 3 (and we could use % to get the remainder). What I don't understand is why the code below still returns an answer of 3. I declared x as a float, so shouldn't the answer be 3.33? #include <iostream> using namespace std; int main() { float x = 10 / 3; cout << x; return 0; // Returns 3, why not 3.33? // }
4 Réponses