Write a program to generate the first n terms of Fibonacci sequence

Previous
Next

Fibonacci series: The series in which the sum of 2 consecutive numbers will be the next number.

Series is: 0, 1, 1, 2, 3, 5, 8, 13…..

#include<stdio.h>
int main()
{
	int n, i, a=0, b=1, c;
	printf("Enter limit : ");	
	scanf("%d", &n);
	printf("Series is : ");
	for(i=1 ; i<=n ; i++)
	{
		printf("%d \t", a);
		c = a+b;
		a = b;
		b = c;
	}
	return 0;	
}
Previous
Next

Courses Enquiry Form