hello , i'm trying to solve this problem
Create a program which generates fibonacci series till a number 'n' where 'n' is entered by the user. For eg. if the user enters 10 then the output would be: 1 1 2 3 5 8 (beginner)
the problem is that the output is 0 1 1 2 3 5 8 13 , but it should be 0 1 1 2 3 5 8 . Can somebody help me?)
#include <cstdlib>
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
int a=10,sum = 0, b = -1 ,c = 1;
while(sum<a) {
sum = (b+c);
cout<<sum<<" ";
b=c;
c=sum;
}
getch();
return 0;
}
p.s the 'n' number is 'a' .