Program to Print Fibonacci Series in C++.

//Program to print Fibonaaci Series.

#include<iostream>

using namespace std;

int main()
{
int i, n, n1=0, n2=1, n3;
cout<<"Enter N to print Fibonnaci Terms : ";
cin>>n;

for(i=1;i<=n;i++)
{
cout<<n1<<"\t";
n3=n1+n2;
n2=n1;
n1=n3;
}
return 0;
}


No comments

Post your comments

Powered by Blogger.