0
Output of 3/4*4
If I write cout<<3/4*4 the output is 0. Shouldn't the output be 3 as / and * have same precedence so code is evaluated left to right so (3/4)*4 =1.
1 Answer
+ 4
Integer division does not preserve the decimal point (if any) of an operation result. You probably meant 3 instead of 1.
3 /4 -> 0.75
0.75 * 4 -> 3