Write a c program to generate fibonacci series upto n terms
#include<stdio.h>
#include<conio.h>
void main()
{
int n,first,second,i,third;
clrscr();
printf("Enter the limit: ");
scanf("%d",&n);
first=0;
second=1;
printf("%d\t%d\t",first,second);
third=first+second;
for(i=2;i<=n;i++)
{
printf("%d\t",third);
first=second;
second=third;
third=first+second;
}
getch();
}
Output:
Enter the limit: 6
No comments: