// prg to illustrate fibonacci series of a given number
#include<stdio.h>
void main()
{
int n,i,past=0,present=1,future;
printf("enter any number:");
scanf("%d",&n);
printf("\n %d \n%d",past,present);
future=past+present;
printf("\n %d",future);
for(i=0;i<n-3;i++)
{
past=present;
present=future;
future=past+present;
printf("\n %d",future);
}
}
output
#include<stdio.h>
void main()
{
int n,i,past=0,present=1,future;
printf("enter any number:");
scanf("%d",&n);
printf("\n %d \n%d",past,present);
future=past+present;
printf("\n %d",future);
for(i=0;i<n-3;i++)
{
past=present;
present=future;
future=past+present;
printf("\n %d",future);
}
}
output
No comments:
Post a Comment