not sure what interviewer meant here, does not look like compiler dependent code, and BTW, last recurrence yield "5" :) and not 8, one possible def is, you have a function with no return and compiler is independent for choosing what to return in this case, just a guess. Not sure about cpp standard
On Tuesday, 25 September 2012 21:27:49 UTC+5:30, Ravi Ranjan wrote: > > #include<iostream.h> > int rec(int i) > { > static int d=1; > if(i>=5) > return i; > d=d+i; > i=i+i; > rec(d); > } > int main() > { > cout<<rec(1); > return 0; > } > > various compilers give diffrent result... why so??? > n how d value is calculated by differnt compilers.. whhat is d correct > output n which compiler to trust?? > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/hV_vZm8wQH0J. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.