050. Write a program to accept a number and print fibonacci series upto that level in C language

#include<stdio.h>
#include<conio.h>
main()
{
	int pre=1,cur=1,temp,i,n;
        clrscr();
	printf("Enter number...");
	scanf("%d",&n);
	printf("%d\t%d",pre,cur);
	for(i=3;i<=n;i++)
		{
		 temp=cur;
		 cur=pre+cur;
		 pre=temp;
		 printf("\t%d",cur);
		}
	getch();
}

Leave a Reply

Your email address will not be published. Required fields are marked *