Sun Nov 03 2019

Fibonacci Series

C++ Programming2806 views

File Name: fibonacci-series.cpp

#include<iostream>
using namespace std;

int main() {
	int a = 0, b = 1, temp, no;
	cout << "Program for Fibonacci Series" << endl;
	cout << "Enter a Number:" << endl;
	cin >> no;

	/* Loop the process using "While Loop" */
	while(b < no) {
		cout << b << endl;
		temp = a + b;
		a = b;
		b = temp;
	}

	return 0;
}



/* Output */
/*
Program for Fibonacci Series
Enter a number:
50

Fibonacci Series -
1
1
2
3
5
8
13
21
34
*/
Reference:

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.