//Write a program to calculate n term of Fibonacci series using for loop 0,1,1,2,3,5,8,..... #include<stdio.h> #include<conio.h> void main() { int n,i,a,b,c=0; clrscr(); printf("Enter value of n:"); scanf("%d",&n); a=0; b=1; if(n=1) printf("0"); else if(n>=2) { printf("0,1"); for(i=1;i<n-1;i++) { c=a+b; printf("%d",c); a=b; b=c; } } getch(); }
Comments
Post a Comment