Advertisement
mahatma_xande

ex04lista05

Aug 22nd, 2019
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.29 KB | None | 0 0
  1. /*
  2. It gives the Fibonacci sequence until the term chosen by the user.
  3. */
  4.  
  5. #include <stdio.h>
  6.  
  7. int main()
  8. {
  9.    
  10.     int x = 0, y = 1, z, w;
  11.    
  12.     printf("Enter z: ");
  13.     scanf("%d", &z);
  14.    
  15.     while(z > 0){
  16.         printf("%d\n", x);
  17.        
  18.         w = y;
  19.         y = x + y;
  20.         x = w;
  21.        
  22.         z = z - 1;
  23.     }
  24.    
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement