Hi,

I have an exam comming up and i noticed something strange in one of the past papers, i wonder if anyone could please explain this to me.

The question is like so..........

a)The following is a recursive method coded in Java:

iv)Trace the method call crank(12).Code:int crank(int n){ if (n==1) return 0; else return 1 + crank(n/2); }

answer is

ii)n=12, n==1? No, 1+crank(12/2)=1+crank(6)

n=n=6, n==1? No, 1+[1 + crank(6/2)]= 1+[1+crank(3)]

n=3,n==1? No, 1+1+[1+crank(3/2)]=1+1+[1+crank(1)]

n=1, n==1? Yes, 1 + 1 + 1 + 0

= 3

i would have though 1.5 would be rounded to 2? is this the same in c++, 3/2 would return an int value of 1?

Thanks for any help.