GTU PPS Program - 19
19. Write a program to generate first n number of Fibonacci series.
- #include<stdio.h>
- #include<conio.h>
- int main()
- {
- int n,a,b,c,i;
- a=0; b=1;
- printf("\nEnter value of n : ");
- scanf("%d",&n);
- printf("\nFibonacci series is\n");
- printf("\n%d\t%d",a,b);
- for(i=1;i<=n-2;i++)
- {
- c=a+b;
- a=b;
- b=c;
- printf("\t%d",b);
- }
- getch();
- return 0;
- }
Comments