One execution path has no return. Most compilers will issue a warning on that. If a function doesn't return a value, that is undefined behavior. It's unclear if the intent is to return rec(d) or i. Better style is to have exactly one return at the end of the function. Don
On Sep 25, 11:57 am, Ravi Ranjan <ravi.cool2...@gmail.com> 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 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.