Advance Programs On For LoopLearn C ProgrammingLearn ProgrammingLoop Control StructuresResources

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

By September 18, 2012 February 5th, 2018 No Comments
#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

DEMO01