SHOW:
|
|
- or go back to the newest paste.
1 | /* | |
2 | ||
3 | ||
4 | - | Write a recursive function that prints the numbers 1 to X back to 1. |
4 | + | Write a recursive function that prints the numbers 1 to X |
5 | ||
6 | * The function must only have one int input. | |
7 | * The function must consist of a single function | |
8 | * The function must not use loops | |
9 | * The function must not use static or global variables. | |
10 | * The function must use printf("%i\n",..) to print the numbers | |
11 | * The function must print before the recursion call | |
12 | * The function must work in theory for any integer between 1 and 2,147,483,647 | |
13 | ||
14 | ||
15 | - | |
15 | + | |
16 | ||
17 | #include <stdio.h> | |
18 | ||
19 | void f (int x); | |
20 | ||
21 | int main(int argsv, char ** argsc) | |
22 | - | printf("Testing an input value of 35"); |
22 | + | |
23 | - | f(35); |
23 | + | int input = 11; |
24 | - | printf("Finished testing an input value of 35"); |
24 | + | printf("Testing an input value of %i\n",input); |
25 | - | return 0; |
25 | + | f(input); |
26 | printf("Finished testing an input value of %i\n",input); | |
27 | return 0; | |
28 | } | |
29 | ||
30 | void f(int x) | |
31 | { | |
32 | //TODO: Implement recursive function | |
33 | } |