Fibonacci Series using for loop in c program
Fibonacci Series is a pattern of numbers where each number is the result of addition of the previous two consecutive numbers.The first two terms of the Fibonacci sequence are 0 followed by 1.
Example : pgm.c
#include<stdio.h> int main(){ int a=-1,b=1,c,i,n; printf("\nEnter the Limit : "); scanf("%d",&n); for(i=0;i<n;i++) { c=a+b; printf("\n%d",c); a=b; b=c; } return 0; }
Output:
Enter the limit: 10
0
1
1
2
3
5
8
13
21
34
0
1
1
2
3
5
8
13
21
34