Warning: mysqli_connect(): (HY000/2002): Connection refused in /home/programc/public_html/wp-content/plugins/wp-pro-quiz/wp-pro-quiz.php on line 38

Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /home/programc/public_html/wp-content/plugins/wp-pro-quiz/wp-pro-quiz.php on line 40

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in /home/programc/public_html/wp-content/plugins/wp-pro-quiz/wp-pro-quiz.php on line 41

Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /home/programc/public_html/wp-content/plugins/wp-pro-quiz/wp-pro-quiz.php on line 45

Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /home/programc/public_html/wp-content/plugins/wp-pro-quiz/wp-pro-quiz.php on line 48

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in /home/programc/public_html/wp-content/plugins/wp-pro-quiz/wp-pro-quiz.php on line 49
c program to print first 20 fibonacci numbers - Get Program Code
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

Restrict Mouse Pointer Position C Graphics Program

This C Program will restrict the Mouse Pointer location or to a particular position or x,y ...

Leave a Reply

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

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