Advertisement
afrinahoque

Print fibonacci series upto n terms

Jun 22nd, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.42 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int n,first=0,second=1,count=0,fibo;
  5.     printf("Enter the number:");
  6.     scanf("%d", &n);
  7.     while (count<n)
  8.     {
  9.         if (count<=1)
  10.         {
  11.             fibo=count;
  12.         }
  13.         else
  14.         {
  15.             fibo=first+second;
  16.             first=second;
  17.             second=fibo;
  18.         }
  19.         printf("%d ", fibo);
  20.         count=count+1;
  21.     }
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement