Recursion is a type of algorithm - that is, you would use a recursive type of code, to solve the problem.
A recursive function is the function that actually uses recursion. Usually, this will be a single function however, sometimes you will have two functions that are mutually recursive: function A calls function B, which calls function A, etc. Relatively rare, but it happens.
Every recursive function has to have an end to the recursion. In a simple function you can still only have it call itself so many times (several hundreds to thousands, so it's a lot), but it has to have that stop in place.
This is a very simple recursive program. Find the stop, and change the value. Do you understand all of it? Remember that ++lo will increment lo BEFORE the parameter is passed to the next call.
Code:
#include <stdio.h>
void printIt(int lo, int hi);
int main() { //
int limit=20;
printIt(0,limit);
printf("\n");
return 0;
}
void printIt(int lo, int hi) {
if(lo == hi)
return;
else {
printf("- ",lo);
printIt(++lo, hi);
}
}