I\'m trying to learn C by writing a simple program to output Fibonacci numbers. It isn\'t working.
fibonacci.h
unsigned int fibonacc
Your approach seems strange, you should have:
main.c) with the main method and that includes fibonacci.hfibonacci.h with the prototype unsigned int fibonacci_recursive(unsigned int n);fibonacci.c with the implementation of the method, and it should include fibonacci.h tooActually you define main function twice too..
main.c
#include
#include "fibonacci.h"
main()
{
unsigned int i;
for (i = 0; i < 10; i++)
{
printf("%d\t%n", fibonacci_recursive(i));
}
getchar();
}
fibonacci.h
unsigned int fibonacci_recursive(unsigned int n);
fibonacci.c
#include "fibonacci.h"
unsigned int fibonacci_recursive(unsigned int n)
{
if (n == 0)
{
return 0;
}
if (n == 1) {
return 1;
}
return fibonacci_recursive(n - 1) + fibonacci_recursive(n - 2);
}