DarkWebCode is a place where you can find a lot of exciting and inspiring stuff about Web Development, Blogging, SEO and many more

Breaking

C program to generate a Fibonacci series.

AIM : 
             To write a C program to generate a Fibonacci series.

ALGORITHM :
     
                 1.Start
                 2.Read num.
                 3.Assign f1=0,f2=1.
                 4.Set loop for i and for all i<num value and calculate f3=f1+f2.
                 5.Display f1.
                 6.Assign f1=f2 and f2=f3.
                 7.Stop.

PROGRAM : 

#include<stdio.h>
#include<conio.h>
void main()
{
           int i,num;
           int f1=0,f2=1,f3;
           printf("Enter how many numbers : ");
           scanf("%d",&num);
           for(i=1;i<=num;i++)
           {
                f3=f1+f2;
                printf("%5d",f1);
                f1=f2;
                f2=f3;
           }
}