#include<stdio.h>
main()
{
int f1=0,f2=1,f3,n,i;
clrscr();
printf("\nEnter
the nth number");
scanf("%d",&n);
printf("\nFirst
%d Fibonacci numbers are :",n);
if(n==1)
{
printf("\n%d",f1);
}
if(n==2)
printf("\n%d
%d\t",f1,f2);
else
{
printf("%d\t%d\t",f1,f2);
i=2;
while(i<n)
{
f3=f1+f2;
printf("%d\t",f3);
f1=f2;
f2=f3;
i++;
}
}
getch();
Comments
Post a Comment