What does 7/9*9 equal (in C and C++)?
-
1
-
0.08642
-
0
-
None of the Above
In C/C++, 7/9 is integer division. Both operands are integers, so the result is 0 (truncated), not 0.777. Then 0*9 = 0. Floating-point division would require at least one float operand (e.g., 7.0/9 or 7/(float)9).
To evaluate the expression 7/9 * 9 in C and C++, we need to consider the data types involved.
By default, when dividing two integers in C and C++, the result will be an integer, which means the decimal part will be truncated.
Let's evaluate the expression step by step:
7/9 = 0 (since both 7 and 9 are integers, the result will be an integer and the decimal part is truncated)
0 * 9 = 0 (0 multiplied by any number is 0)
Therefore, the result of the expression 7/9 * 9 in C and C++ is 0.
Hence, the correct answer is option C.