This is a c program to print fibonacci numbers where fibonacci numbers are those where every next number in the series is the sum of the previous two numbers and the series starts with the former numbers 0 and 1. So fibonacci series is:

0, 1, 1, 2, 3, 5, 8, 13, 21, 34 ….. so on.

Now: take two starting variables a and b where

a = 0; b=1;

c= a+b; for every next number

but then

a=b;

b=c;

**ALSO CHECK :
**

**java program to print first 20 fibonacci numbers****c program to print fibonacci numbers using recursion**

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
#include "stdio.h" #include "conio.h" void main() { int a=,b=1,c,count=2; printf("%d ",a); // printing the starting two numbers 0 and 1 printf("%d ",b); while(count!=20) // if you want first 100 fibonacci numbers then change 20 to 100 accordingly { c=a+b; // every next number is addition of previous two numbers count++; printf("%d ",c); a=b; // changing the previous two numbers b=c; } } |