C++ Program to print fibonacci series by using for loop


#include<iostream> using namespace std; int main(){ int i,c; int a=0,b=1; cout<<a<<","; cout<<b<<","; for(i=2;i<20;i++){ c=a+b; cout<<c<<","; a=b; b=c; } return 0; }

Output:-

0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,