Fibonacci Series Such a series in which the sum of two preceding numbers is the next number i.e 1 1 2 3 5 8 13 21..... Following is the logic for Fibonacci series..... #include<iostream> using namespace std; void main() { int n, t1 = 0, t2 = 1, nextTerm = 0; cout << "Enter the number of terms: \n"; cin >> n; cout << "Fibonacci Series: \n"; for (int i = 1; i <= n; ++i) { if (i == 1) { cout << t1 << " "; continue; } if (i == 2) { cout << t2 << " "; continue; } nextTerm = t1 + t2; t1 = t2; t2 = nextTerm; cout << nextTerm << " "; } system("pause"); }
Stories, events, reviews, news and everything you want is here