Write a program to print the fibonacci series till a given number in c++.

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int n, first = 0, second = 1, next, c;

cout<<“Enter the number of terms\n”; cin>>n;

cout<<“\nFirst “<<n<<” terms of Fibonacci series are :-\n”;

for ( c = 0 ; c < n ; c++ )
{
if ( c <= 1 )
next = c;
else
{
next = first + second;
first = second;
second = next;
}
cout<<“\nfibonacci of”<<c<<” is “<<next;
}
getch();
return 0;

}


Untitled-1 copy