home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / ctutor2.zip / RECURSON.C < prev    next >
Text File  |  1989-11-10  |  862b  |  44 lines

  1.                      /* Chapter 5 - Program 5 */
  2. #include "stdio.h"            /* Contains prototype for printf    */
  3. void count_dn(int count);     /* Prototype for count_dn           */
  4.  
  5. void main()
  6. {
  7. int index;
  8.  
  9.    index = 8;
  10.    count_dn(index);
  11. }
  12.  
  13. void count_dn(int count)
  14. {
  15.    count--;
  16.    printf("The value of the count is %d\n",count);
  17.    if (count > 0)
  18.       count_dn(count);
  19.    printf("Now the count is %d\n",count);
  20. }
  21.  
  22.  
  23.  
  24. /* Result of execution
  25.  
  26. The value of the count is 7
  27. The value of the count is 6
  28. The value of the count is 5
  29. The value of the count is 4
  30. The value of the count is 3
  31. The value of the count is 2
  32. The value of the count is 1
  33. The value of the count is 0
  34. Now the count is 0
  35. Now the count is 1
  36. Now the count is 2
  37. Now the count is 3
  38. Now the count is 4
  39. Now the count is 5
  40. Now the count is 6
  41. Now the count is 7
  42.  
  43. */
  44.