how to write the fibonacci series by accepting the value of terms of the series from the user?

#include<iostream>
using namespace std;
int main(){

   int num,first=0,second=1,next;
   cout << "Enter the number " << endl;
   cin >> num;
   cout << "First "<<num<<"terms of Fibonacci series are :-"<<endl;
   for ( int loop=0;loop<num;loop++){

         next=first+second;
         first=second;
         second=next;

      cout<<next<<endl;
   }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.