Tuesday 10 January 2012

Print Fibonacci Series upto a range

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

void main()
{
    int a=0,b=1,c,n,i;
    clrscr();
    printf("Enter the range::\n");
    scanf("%d",&n);
    printf("The series are....\n");
    printf("%d\n%d\n",a,b);
    for(i=2;i<n;i++)
    {
        c=a+b;
        printf("%d\n",c);
        a=b;
        b=c;
    }
    getch();
}

No comments:

Post a Comment