Try this, it does work (tested it myself)
Then explain to your teacher why you dynamically allocated memory... 
Code:
unsigned long int fib(unsigned int num)
{
int i = 1;
unsigned long int value = 0;
unsigned long int* fibarray;
fibarray = (unsigned long int*) calloc(num + 1, sizeof(unsigned long int)); // Potentially create a memory leak
fibarray[0] = 0;
fibarray[1] = 1; // Prime the pump, so to speak
while(i < num)
{
fibarray[i + 1] = fibarray[i] + fibarray[i - 1];
++i;
}
value = fibarray[num];
free(fibarray); // Avoid a memory leak
return value;
}
Here is another version that doesn't use an array. Probably better for this assignment.
Code:
unsigned long int fib(unsigned long int num)
{
unsigned long int first = 0;
unsigned long int second = 1;
unsigned long int third = num;
for(int i = 1; i < num; ++i)
{
third = second + first;
first = second;
second = third;
}
return third;
}
And here is the recursive solution *WARNING* WAY SLOW!
Code:
unsigned long int fib(unsigned long int num)
{
if (num == 0)
return 0;
else if (num == 1)
return 1;
else
return fib(num - 2) + fib(num - 1);
}
Hope that gives you a feel for how to do this.