#include <iostream>
using namespace std;

int main() {
    int numTerms, prev=0, curr=1, next;
    cout << "Enter the number of terms in the Fibonacci series: ";
    cin >> numTerms;
    cout << prev << " " << curr << " ";
    for(int i=2; i<numTerms; i++) {
        next = prev + curr;
        cout << next << " ";
        prev = curr;
        curr = next;
    }
    cout << endl;
    return 0;
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: