fork download
  1. #include <stdio.h>
  2.  
  3. void printer(int a);
  4.  
  5. int main()
  6. {
  7. int number;
  8. printf("Enter a number: ");
  9. scanf("%d", &number);
  10. printf("The natural numbers are: ");
  11. printer(number);
  12. }
  13.  
  14. void printer(int a)
  15. {
  16. if (a <= 0)
  17. return;
  18. printer(--a);
  19. printf("%d ", a);
  20. }
Success #stdin #stdout 0s 5280KB
stdin
45
stdout
Enter a number: The natural numbers are: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44