Fibonacci Series using For loop #c
The Fibonacci Series is like 0,1,1,2,3,5,8,13------------
or
0 , 0+1, 1+1 ,2+1, 3+2, 5+3, 8+5
or
0 , 0+1, 1+1 ,2+1, 3+2, 5+3, 8+5
// A program to display Fibonacci Series using For loop in c. #include<stdio.h> #include<conio.h> void main() { int n,i,x=1,y=0,z=0; clrscr(); printf("Enter the limit\n"); scanf("%d",&n); for (i=1;i<=n;i++) { printf("%d,",z); z=x+y; x=y; y=z; } getch(); }
Comments
Post a Comment