I got this as a class exercise. I had to analyze the output without running it and I figured that
the output should be num=4.
But actually the output of this code