I think this is a problem of accuracy. The operators / and * have the same priority, so 7/9 * 9 is evaluated from left to right with (7/9) * 9. The catch is that (7/9) is 0 in integer arithmetic. When you explain them as a float, this operation is performed in floating point, which can store 7/9 with more precision than int.
If you want to perform calculations on one line without error, try:
cout <7.0f / 9.0f * 9.0f;
source share