answersLogoWhite

0

I am a beginner at C++ but my professor gave us a similar one to this which was to display 4321. So i just modified it to fit your satisfaction.

Code:

void f(int n)

{

cout<<n;

if(n<=4) f(n+1);

}

calling statement: f(1) Output:1234

Trace :

f(1)

/ \

1 f(2)

/ \

2 f(3)

/ \

3 f(4)

/

4

User Avatar

Wiki User

14y ago

What else can I help you with?