Fibonacci series - C Programming

Posted on:
tags: , , ,
Fibonacci series
19/10/2011



#include<stdio.h>
#include<conio.h>
void main()
{
int t,a,q,x,y;
clrscr();
printf("\t\tITS A FIBBONACCI PROGRAM\n");
printf("\tEnter the desire number of terms:");
scanf("%d",&a); //taking number as input.


x=0; y=1; // initializing value for variable x and y.
t=2; // initailly value of t will be 2 because we will print 0 and 1 from different instruction.
q=0;//initialising variable q as 0,since it is calculating sum & summation identity is 0.
printf("%d\t",x);//printing the value of 1st term of series.
printf("%d\t",y);//printing the value of 2nd term of series.


while(t<a)//starting of loop,loop will execute untill condition is satisfied.
{
q=x+y;
x=y;
y=q;
printf("%d\t",q);//printing the value of rest term of series upto which you have desired.
t=t+1;//incrementaion statement.
}//end of loop.
getch();
}// end of program.




if you have any query regarding the program then free to ask at youthtalentauzzar@gmail.com




No comments:

Post a Comment

< >