include <iostream>
using namespace std;
int main() {
int n, firstTerm = 1, secondTerm = 1, nextTerm;
cout << "Enter number of terms: ";
cin >> n;
cout << "Fibonacci Series: " << firstTerm << " + " << secondTerm << " + ";
for (int i = 1; i <= n-2; ++i) {
nextTerm = firstTerm + secondTerm;
cout << nextTerm << " + ";
firstTerm = secondTerm;
secondTerm = nextTerm;
}
return 0;
}
Output
Enter number of terms: 11
Fibonacci Series: 1 + 1 + 2 + 3 + 5 + 8 + 13 + 21 + 34 + 55 + 89 +
using namespace std;
int main() {
int n, firstTerm = 1, secondTerm = 1, nextTerm;
cout << "Enter number of terms: ";
cin >> n;
cout << "Fibonacci Series: " << firstTerm << " + " << secondTerm << " + ";
for (int i = 1; i <= n-2; ++i) {
nextTerm = firstTerm + secondTerm;
cout << nextTerm << " + ";
firstTerm = secondTerm;
secondTerm = nextTerm;
}
return 0;
}
Output
Enter number of terms: 11
Fibonacci Series: 1 + 1 + 2 + 3 + 5 + 8 + 13 + 21 + 34 + 55 + 89 +