abhijeetgund34 / C-language-

0 stars 0 forks source link

Fibonacci series #2

Open abhijeetgund34 opened 7 years ago

abhijeetgund34 commented 7 years ago

include

include

int main()

{ int f=0,s=1,next,i,no; clrscr(); printf("enter a no of terms\n"); scanf("%d",&no); printf("first %d terms of fibbonacci series are:\n",no); for(i=0;i<no;i++) { if(i<=1) next=i;

else { next=f+s; f=s; s=next; } printf("%d\n",next); } getch(); return 0; }

abhijeetgund34 commented 7 years ago

include

include

void main() { int t1=0,t2=1,next=0,n; clrscr(); printf("enter positive no:"); scanf("%d",&n); printf("Fibonacci series: %d, %d,", t1, t2); next=t1+t2; while(next<=n) { printf("%d",next); t1=t2; t2=next; next=t1+t2; } getch(); }