Social Icons

Tuesday, 11 February 2014

Program to print Fibonacci series

#include<stdio.h>
#include<conio.h>

void main()
{
int first=0,second=1,third,i,n;
clrscr(); 

printf("\n How many elements : ");
scanf("%d",&n);
printf("\n %d %d",first,second);

for(i=2;i<n;++i)
{
third=first+second;
printf(" %d",third);
first=second;
second=third;
}
getch(); 
}


                                                                  Output

No comments:

Post a Comment