Fibonacci Series Using C program
C Program:
Output 1:
Output 2:
From the above program,
ü Let n=5.
i=0 |
i<=n |
Print t1 |
temp=t1+t2 |
t1=t2 |
t2=temp |
i++ |
0 |
0<=5 |
0 |
temp=0+1 temp=1 |
t1=1 |
t2=1 |
1 |
1 |
1<=5 |
1 |
temp=1+1 temp=2 |
t1=1 |
t2=2 |
2 |
2 |
2<=5 |
1 |
temp=1+2 temp=3 |
t1=2 |
t2=3 |
3 |
3 |
3<=5 |
2 |
temp=2+3 temp=5 |
t1=3 |
t2=5 |
4 |
4 |
4<=5 |
3 |
temp=3+5 temp=8 |
t1=5 |
t2=8 |
5 |
5 |
5<=5 |
5 |
temp=5+8 temp=13 |
t1=8 |
t2=13 |
6 |
6 |
6<=5 false |
Doesn’t execute |
ü final output will be as 0 1 1 2 3 5.
0 Comments