Fibonacci Series Program in C Using DO While Loop

Write a Fibonacci Series Program in C Using While Loop. C program to print fibonacci series. We are going to use a simple method to print the Fibonacci series. As we know the Fibonacci Series is started with Zero (0) and the next Element is One (1). The next step is to add the previous two elements and print the next element of the Fibonacci Series.

Fibonacci Series: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34. Fibonacci Series is up to 10 Elements.

Fibonacci Series start with a Zero and the next element is one then first we print 0 and 1. Now add two previous elements and print the next element as 0+1=1. Repeat that process until n terms.

1 + 1 = 2
1 + 2 = 3
2 + 3 = 5
3 + 5 = 8
5 + 8 = 13
8 + 13 = 21
13 + 21 = 34

Read: C++ Program To Find Large Fibonacci Series

Fibonacci Series Program in C Using DO While Loop

``````#include <stdio.h>

int main()
{
/*fibonacci Series Program in C*/
int count, n, t1 = 0, t2 = 1, Temp = 0;

printf("Enter the Number of Terms:\n");
scanf("%d", &n);

printf("\nFibonacci Series: %d, %d, ", t1, t2);
count = 2;
while (count < n)
{
Temp = t1 + t2;
t1 = t2;
t2 = Temp;
++count;
printf("%d, ", Temp);
}

return 0;
}``````

Previous Post
Next Post