Friday, 21 February 2014

Write a C program to print the first n number of terms of fibonacci series.

#include<stdio.h>
main()
{   
    int a=1,b=1,i=1,n,temp;
    printf("\nEnter number of terms=");
    scanf("%d",&n);
    printf("\nThe fibonacci series is\n");
    while(i<=n)
    {
        printf("%d ",a);
        temp=a;
        a=b;
        b=temp+a;
        i++;
    }
}

No comments:

Post a Comment