In: Computer Science
CODE:
#include<iostream>
using namespace std;
int main()
{
int a = 0, b = 1;//declaring initial values.
int c;//next number of series.
cout<<"The fibonocci series is : "<<a<<",
"<<b;
//we iterate 20 times to generate 20 numbers.
for(int i= 0 ; i < 20 ;i++)
{
c = a + b;//adding before 2 numbers to get next number.
a = b;//changing a to b.
b = c;//changing b to c.
cout << ", "<< c;//printing the next number.
}
}
CODE
ATTACHMENTS:
OUTPUT:
Please do comment for any queries.
Please like it.
Thank you.