Skip to content

Commit 4ccfe50

Browse files
authored
Create Fibonacci Numbers
This is a basic fibonacci program which is easy to understand. It provides a basic understanding about the fibonacci series,
1 parent 4634fa3 commit 4ccfe50

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

Fibonacci Numbers

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# include <iostream>
2+
# include <bits/stdc++.h>
3+
4+
using namespace std;
5+
6+
void input(int &n)
7+
{
8+
cin>>n;
9+
}
10+
11+
void display(int &c)
12+
{
13+
cout<<c<<" ";
14+
}
15+
16+
void fibo(int &n)
17+
{
18+
int a=0, b=1, c=0;
19+
20+
while(n--)
21+
{
22+
display(c);
23+
a=b;
24+
b=c;
25+
c=a+b;
26+
}
27+
}
28+
29+
int main()
30+
{
31+
int n; //for no. of elements
32+
33+
input(n);
34+
35+
fibo(n);
36+
37+
return 0;
38+
}

0 commit comments

Comments
 (0)