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
Also See:   C program to remove extra lines or blank lines from a file

Check Also

How to Solve Linear Equation in One Variable In C Programming?

C Program to Solve any Linear Equation in One Variable Find complete C program to ...

Leave a Reply

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