Advertisement
RIFATKHAN1

print fibonacci series upto n terms.

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