Home / C / c program to print first 20 fibonacci numbers

c program to print first 20 fibonacci numbers

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 :

#include "stdio.h"
#include "conio.h"
void main()
{
int a=0,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;
}
}

OUTPUT:

c program to print fibonacci series
c program for fibonacci numbers

Check Also

Hide Mouse Pointer C Program

How to Hide a Mouse Pointer Program in C : This program will show and hide ...

Leave a Reply

Your email address will not be published. Required fields are marked *

Preventing spam * Time limit is exhausted. Please reload the CAPTCHA.