#include<iostream> #include<iomanip> using namespace std; int main(){ int a=0,b=1,c,num; cout<<"enter the nujmber of terms: "<<endl; cin>>num; cout<<a<<' '<<b; for(int i=1;i<=num-2;i++){ c=a+b; a=b; b=c; cout<<' '<<c; } cout<<endl; return 0; }
#include<iostream> #include<iomanip> using namespace std; int main(){ int a=0,b=1,c,num; cout<<"enter the nujmber of terms: "<<endl; cin>>num; cout<<a<<' '<<b; for(int i=1;i<=num-2;i++){ c=a+b; a=b; b=c; cout<<' '<<c; } cout<<endl; return 0; }