Code:
#include <iostream> 
#include <stdlib.h> 
using namespace std; 

void fun(int x); 

int main(void) 
{ 
   fun(3); 
} 

void fun(int x) 
{ 
   if (x != 1) 
      fun(x - 1); // fun calls fun 

   cout << x << endl; 
}
That should work the way you want.