Pages

Sunday, 20 May 2012

program to print fabonnaci series of given number input by user


81./*Write a program to print fabonnaci series of given number input by user.*/

#include<stdio.h>
#include<conio.h>
main()
{
            int f=0,f1=1,f2=0,n,i=0;
            clrscr();
            printf("Enter any value");
            scanf("%d",&n);
            while(i<n)
            {
             printf("%4d",f2);
             f=f1+f2;
             f1=f2;
             f2=f;
             i++;
             }
             getch();
 }

OUTPUT

            Enter any value: 5
            0 1 1 2 3

No comments:

Post a Comment