7. Write a program to construct a Fibonacci series upto n terms.

 SOURCE CODE:


#include <stdio.h>

int main()
{   int t1=0,t2=1,n,next_term;
    printf("enter how many terms you want\n");
    scanf("%d",&n);
    printf("%d,%d,",t1,t2);
    next_term=t1+t2;
    for(int i=3;i<=n;i++)
    {  printf("%d,",next_term);
       t1=t2;
       t2=next_term;
       next_term=t1+t2;
    }

    return 0;
}


Comments

Popular posts from this blog

10. Write a program to find the sum of following series 1-X1/1!+X2/2!- ............Xn/n!.

5. Write a program to receive marks of physics, chemistry & maths from user & check its eligibility for course if a) Marks of physics > 40 b) Marks of chemistry > 50 c) Marks of math’s > 60 d) Total of physics & math’s marks > 150 or e) Total of three subjects marks > 200