GTU PPS Program - 19

19. Write a program to generate first n number of Fibonacci series.

  1. #include<stdio.h>
  2. #include<conio.h>
  3. int main()
  4. {
  5. int n,a,b,c,i;
  6. a=0; b=1;
  7. printf("\nEnter value of n : ");
  8. scanf("%d",&n);
  9. printf("\nFibonacci series is\n");
  10. printf("\n%d\t%d",a,b);
  11. for(i=1;i<=n-2;i++)
  12. {
  13. c=a+b;
  14. a=b;
  15. b=c;
  16. printf("\t%d",b);
  17. }
  18. getch();
  19. return 0;
  20. }

Sample output

Comments

YouTube

Popular posts from this blog

GTU OOP Program - 17 tic-tac-toe

GTU OS Program - 11 Filters

GTU OS Program - 8