Hello. I'm just beginning learning C++ and I'm having a problem with simple division. First, here's the code that I'm having a problem with. . .
The program works, but I'd like to know how to simply divide one by seven without having to define them as doubles first. For such a small program, it really doesn't make a difference but I want to know why something like the following doesn't work. . .
double number = 1;
double eight = .125*number;
double one = 1;
double seven = 7;
double fract = one/seven;
double seventh = fract * number;
double test = 4100 + seventh + eight;
std::cout << number << " " << seventh << " " << eight << " " << test << std::endl;
if (test == number)
Finally, if it's not too much trouble, can someone explain the right way to do the following? I'm pretty sure that this isn't the right way.
double test = 4100 + ((1/7)*number) + ((1/8)*number);
Thank you very much.