Monday, 24 August 2015

Write a C program to Print Fibonacci Series

#include<stdio.h>
#include<conio.h>

int main()
{
            int n1=0,n2=1,n3=1,n,i;
            clrscr();

            printf("Enter the Number : ");
            scanf("%d",&n);

            printf("\n");
            for(i=1;i<=n;i++)
            {
                        printf(" %d ",n3);
                        n3=n1+n2;
                        n1=n2;
                        n2=n3;
            }
            getch();

            return 0;

}

No comments:

Post a Comment