codescracker


c

C Program to Print Fibonacci Series



« Previous Program Next Program »


Print Fibonacci Series in C

To print Fibonacci series in C programming, first print the starting two number of the Fibonacci series and make a while loop to start printing the next number of the Fibonacci series. Use the three variable say a, b and c. Place b in a and c in b then place a+b in c to print the value of c to make Fibonacci series

C Programming Code to Print Fibonacci Series

Following C program ask to the user to enter the limit (upto which he/she want) to print the Fibonacci series:

/* C Program - Print Fibonacci Series */
		
#include<stdio.h>
#include<conio.h>
void main()
{
	clrscr();
	int a=0, b=1, c=0, limit;
	printf("Upto How many term ? ");
	scanf("%d",&limit);
	printf("Fabonacci Series : %d  %d  ",a, b);   // first two term
	c=a+b;
	limit=limit-2;   // decrease limit by 2. since two number already printed
	while(limit)
	{
		printf("%d  ",c);
		a=b;
		b=c;
		c=a+b;
		limit--;
	}
	getch();
}

When the above c program is compile and executed, it will produce the following result:

c program print fibonacci series

Same Program in Other Programming Language

You may also like same program in other programming languages:


« Previous Program Next Program »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test