Code Scrappers


Fabonacci series C program


                    #include<stdio.h>
                    #include<stdlib.h>

                    void main()

                    {

                        int i, n, nextTerm;

                        int term1 = 0, term2 = 1;


                        printf("enter the number of terms:  ");

                        scanf("%d", &n);


                        printf("Fibonacci Series is:  \n ");


                        for (i = 1; i <= n; i++)

                        {

                            printf("%d\n ", term1);

                            nextTerm = term1 + term2;

                            term1 = term2;

                            term2 = nextTerm;

                        }

                    }
                



Output

            Enter the no. of terms : 8

            0 1 1 2 3 5 8 13