From fd5486bf7282dfaf902c3c62c35ca0eb7ae6660d Mon Sep 17 00:00:00 2001 From: nilanshuvishesh19 <44288061+nilanshuvishesh19@users.noreply.github.com> Date: Fri, 19 Oct 2018 14:07:52 +0530 Subject: [PATCH] fibonacciSeries --- fibonacciSeries | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 fibonacciSeries diff --git a/fibonacciSeries b/fibonacciSeries new file mode 100644 index 0000000..f525467 --- /dev/null +++ b/fibonacciSeries @@ -0,0 +1,30 @@ +#include + +using namespace std; + +main() +{ + int n, c, first = 0, second = 1, next; + + cout << "Enter the number of terms of Fibonacci series you want" << endl; + cin >> n; + + cout << "First " << n << " terms of Fibonacci series are :- " << endl; + + for ( c = 0 ; c < n ; c++ ) + { + if ( c <= 1 ) + next = c; + else + { + next = first + second; + first = second; + second = next; + } + cout << next << endl; + } + + return 0; +} + +// finish