Sunday, 15 September 2013

c - Please, can you help me with this recursive function? -



c - Please, can you help me with this recursive function? -

#include <stdio.h> int fun (int x) { if (x<1) return(1); else printf("%d %d \n", x, fun(x-1)); } int main() { int x,y; x = 5; y = fun(x); printf("\n x = %d f(x) = %d \n", x, y); homecoming 0; }

this programme contains recursive function count numbers. there in output cannot understand. there screenshot of output @ next link:

https://onedrive.live.com/redir?resid=be4862d617298d2c!886&authkey=!aa03bf8dq5w4s9y&v=3&ithint=photo%2cpng

why right column (red circuled) shown? thought column ones instead of that.

because function fun didn't have homecoming value when x >= 1.

and 5 homecoming value of printf("%d %d \n", x, fun(x-1)); because has output 5 characters.

c recursion

No comments:

Post a Comment