I was attempting to recreate the fibonacci sequence and I made a working code but my code will refuse to use a number above 12. any ideas what is wrong?
#include <stdio.h>
#include <stdlib.h>
int main()
{
const int user = 1;
long int fib[user];
int i = 0;
int pastpast = 0;
int past = 0;
printf("how many numbers should i print?:");
scanf("%d", &user); //asks how many numbers to do
for(i = 0; i < user; i++)
{
fib[i] = 0;
} // sets array to 0
i=0;
while(i != user)
{
if(i == 0)
{
fib[i] = 1;
i++;
}
if(i == 1)
{
fib[i] = 1;
i++;
} //sets the first and second numbers to 1
pastpast = fib[i-2];
past = fib[i-1];
fib[i] = past + pastpast;
i++; // goes through the sequence
}
for(i = 0; i < user; i++)
{
printf("%d,", fib[i]);
} //prints all the numbers
printf("\n");
return 0;
}