# Fibonacci Series Program and Algorithm in C

Fibonacci series is a series of nos.(0,1,1,2,3,5,8………so on) in which a new number is found by adding(+) up to 2 nos. before it for example 0+1=1,   1+1=2,   2+1=3,  3+2=5, 5+3=8…….)

## ALGORITHM TO PRINT THE FIBONACCI SERIES

Step 1: Start

Step 2: Assign first<-0 and second<-1

Step 3: Print first,second

Step 4:Counter<-2;

Step 5: while(counter<n)

Third<-first+second

Print third

Counter<-counter+1;

Firt<-second;

Second<-third;

End while

Step 6:Exit

//PROGRAM IN C TO PRINT THE FIBONACCI SERIES

#include<stdio.h>

#include<conio.h>

void main()

{

int fir,sec,thir,no,countr;

clrscr();

countr=2;

fir=0;

sec=1;

printf("How many nos. u want to generate.\n");

scanf("%d",&no);

if(no==0)

printf("Sorry!Not available");

else if(no==1)

printf("%d",fir);

else if(no==2)

printf("%d%d",fir,sec);

else

{

printf("%d%d",fir,sec);

while(countr<no)

{

thir=fir+sec;

printf("\n%d",thir);

countr=countr+1;

fir=sec;

sec=thir;

}

}

getch();

}      }

Output...

### //SECOND EXAMPLE

#include<stdio.h>

#include<conio.h>

void main()

{

long fir,sec,sum,final_sum;

int i,n;

fir=0;

sec=1;

printf("Pls Enter th value of final_sum for fibonacci");

scanf("%ld",&final_sum);

sum=fir+sec;

while(sum<=final_sum)

{

sum=fir+sec;

printf("%ld",sum);

fir=sec;

sec=sum;

printf("\n");

}

getch();

}

Output......

### About Us

Rekha Setia is a passionate blogger of Extra Computer Notes. if you have any ideas or any request me @