Hi,
This question is from my exam:
Predict the output of the following program:
I solved it like this:Code:#include <iostream> using namespace std; int main() { int i=3,j; j=++i*++i*++i; cout<<j; return 0; }
But the correct answer (according to the teacher) is:4*5*6= 120
When I compile this program, it gives warning: operation on ‘i’ may be undefined6*6*6 = 216
and then prints out 150 as the output!
Please help me figure out what's wrong.
Thank you.