Friday, November 23, 2012

WRITE A C PROGRAM TO GENERATE FIBONACCI SERIES UPTO A GIVEN NUMBER


/* WRITE A C PROGRAM TO GENERATE FIBONACCI SERIES UPTO A GIVEN    NUMBER */

#include<stdio.h>
#include<conio.h>
void main()
{
            int a=0,b=1,c,n;
            clrscr();
            printf("Enter the limit to Generate Fibonacci No.s : ");
            scanf("%d",&n);
            printf("\n%d\n%d",a,b);
            for(c=a+b;c<=n;c=a+b,a=b,b=c)
                        printf("\n%d",c);
            getch();
}
/*
            =====OUT PUT=====

            Enter the limit to Generate Fibonacci No.s : 25

            0
            1
            1
            1
            2
            3
            5
            8
            13
            21

*/

2 comments: