Write a C program to print fibonacci series up to n terms?


#include<stdio.h>
#include<conio.h>
void main()
{
    int a = 0, b = 1;
    int i, c, n;
    printf("Enter number of turms of serie: ");
    scanf("%d",&n);
    printf("%d %d",a ,b);
    for(i=0; i<=n; i++)
    {
        c = a+b;
        a = b;
        b = c;
        printf(" %d",c);
    }
    getch();
}

Output:


Comments

Popular posts from this blog

Larch Soft Pvt. Ltd. - Best Website & Hosting Provider