c 2b 2b program to print fibonacci series

Solutions on MaxInterview for c 2b 2b program to print fibonacci series by the best coders in the world

showing results for - "c 2b 2b program to print fibonacci series"
Alejandro
11 Apr 2019
1#include<iostream>
2using namespace std;
3int main()
4{  
5   int n;
6   int a[n];
7   cout<<"Enter no of terms:-\t";
8   cin>>n;
9   a[0]=0;
10   a[1]=1;
11   cout<<a[0]<<" "<<a[1];
12   for (int i = 2; i <=n; i++)
13   {
14       a[i]=a[i-1]+a[i-2];
15       cout<<" ";
16       cout<<a[i];
17   }
18 return 0;
19}