New to C++, I'm trying to create a fibonacci calculator where it will list all the steps up to a user given point and using a user given starting point.
#include <iostream>
using namespace std;
int main()
{
int initial;
int steps;
int values[] = {};
int x = 0;
char hold;
cout << "Start at: "; cin >> initial;
values[0] = initial;
cout << "Steps: "; cin >> steps;
while(x < steps){
if(x == 0){
values[(1)] = values[0] + 1;
}else {
values[(x+1)] = values[x] + values[(x-1)];
}
x++;
cout << values[x] << endl;
}
}
I'm not getting the output i'm expecting at all :P it looks like it has something to do with the values[(x+1)] = values[x] + values[(x-1)]; line. Thanks for any help :)