According to C ++ How to Program, 8th ed., during the operation of two numbers (eg 10/3) the fractional part of the result is lost before being stored in the variable. For this to be avoided, we can resort to explicit conversion using the static_cast operator. So I wrote the code like this:
#include <iostream>
int main(){
double flutuante;
int tres = 3;
int dez = 10;
flutuante = static_cast<double> (dez / tres);
std::cout <<" resultdo: " << flutuante;
}
Waiting as a result: 3,333 ... but the result I get is simply 3.