I wrote this code to produce a fibonacci seqeunce to a cretain number. However, when you get to a certain number, it starts producing negative numbers, and I don't know what to do.
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
long lMax;
lMax = 0;
long x;
int Count;
cout << "Fibonacci Sequence Generator\nGenerate to what number?\n";
cin >> lMax;
int FibOut[lMax+1];
FibOut[1] = 1;
FibOut[2] = 1;
Count = 0;
do
{
Count++;
if (Count < 3)
{
Count = 3;
}
FibOut[Count] = FibOut[Count - 2] + FibOut[Count - 1];
}
while (Count < lMax);
Count = 0;
do
{
Count++;
cout << FibOut[Count] << "\n";
}
while (Count < lMax);
cout << "Press ENTER to end...\n";
x = cin.get();
return 0;
}