SAADQUAMER

Fibonacci series upto n terms

Jun 21st, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.35 KB | None | 0 0
  1. // C program to print fibonacci series upto n terms.
  2. #include <stdio.h>
  3. int main(){
  4. int x,FN=0,SN=1,temp, i;
  5. printf("Enter a number :");
  6. scanf("%d", &x);
  7. printf("First %d terms of Fibonacci series are:\n", x);
  8. for (i=0; i<x; i++){
  9. if (i<=1)
  10.     temp=i;
  11. else{
  12.     temp=FN+SN;
  13.     FN=SN;
  14.     SN=temp;}
  15. printf("%d\n",temp);
  16. }
  17.  
  18. return 0;
  19.  
  20. }
Advertisement
Add Comment
Please, Sign In to add comment