Horje
Fibonacci in c++ Code Example
Fibonacci in c++
#include<iostream>
using namespace std;

int main()
{
	int n, t1 = 0, t2 = 1, sum = 0;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		if (i == 1)
			cout << t1 << " ";
		else if (i == 2)
			cout << t2 << " ";
		else
		{
			sum = t1 + t2;
			cout << sum << " ";
			t1 = t2;
			t2 = sum;
		}
	}
	return 0;
}




Cpp

Related
Define and show the implementation of the functions of an arrayList. Code Example Define and show the implementation of the functions of an arrayList. Code Example
how to initialize a vector of pairs in c++ Code Example how to initialize a vector of pairs in c++ Code Example
c++ sigabrt Code Example c++ sigabrt Code Example
convert kelvin to Fahrenheit Code Example convert kelvin to Fahrenheit Code Example
unreal engine delay c++ Code Example unreal engine delay c++ Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9