#include <iostream> using namespace std; int main() { int a=0,b=1,c,sum,elements; cout<<"enter he number of elements"<<endl; cin>>elements; for(int i=2;i<=elements;i++){ if(i==1){ cout<<a;} else if(i==2){cout<<a<<' '<<b<<' ';} else {c=a+b; cout<<' '<<c<<' '; a=b; b=c; } } return 0; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter