loader image

C program to find first n fibonacci numbers

Aim: Print first n fibonacci numbers using C.

#include<stdio.h>
#include<conio.h>
int main()
{
	int a,b,c,i,n;
	printf("Enter the limit : ");
	scanf("%d",&n);
	printf("\nThe first %d fibonacci numbers are : ",n);
	for(a=1,b=0,i=0;i<n;i++)
	{
		c=a+b;
		printf("%d ",c);
		a=b;
		b=c;
	}
	return 0;
}
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Scroll to Top