C Program to Print Fibonacci Numbers

Before looking into the program to print Fibonacci numbers, let us look into what really it is.  Fibonacci numbers are a sequence of numbers known as a Fibonacci sequence which is characterized by the fact that ‘every number after the first two is the sum of the two preceding ones’ as shown below:

1, 1, 2, 3, 5, 8, 13, 21, …

From the sequence given above, we can see that there exists a recurrence relation as:

F(n) = F(n-1)+F(n-2)

Let us use this relation to print the Fibonacci numbers, using a recursive method.

int FIB(int);
int n, i, c=0;
printf("\nEnter the number of terms:");
scanf("%d", &n);
for(i=0; i<n; i++)
printf("%d ", FIB(i));
return 0;
int FIB(int x)
return 0;
else if(x==1)
return 1;




Sonam Dargay

Kuzu Zangpo la! I am Sonam Dargay, a student in the College of Science and Technology affiliated to The Royal University of Bhutan. I am a tech enthusiast student, studying Bachelor of Engineering in Information Technology.

You may also like...

%d bloggers like this: