This post contains a total of 7+ C Program Examples with Source Code to Print Fibonacci Series of a Number. All these Fibonacci Series programs are made using C Language.
You can use the source code of these examples with credits to the original owner.
Related Posts
C Programs to Print Fibonacci Series
1. By BroFar
Made by BroFar. Program to print Fibonacci series of the given number of terms. Source
Enter the number of terms for the Fibonacci Series: 10 Fibonacci Series: 0 1 1 2 3 5 8 13 21 34
#include <stdio.h>
int main() {
int i, r, t1 = 0, t2 = 1, trms;
printf("Enter the number of terms for the Fibonacci Series: \n");
scanf("%d", &r);
if ( r > 47) {
r = 47;
}
printf("Created by BroFarOps on 11-22-2018\n\n");
printf("Fibonacci Series: ");
for (i = 1; i <= r; ++i) {
printf("%d \n", t1);
trms = t1 + t2; t1 = t2;
t2 = trms;
}
printf("\n\nreference my post at:\n www.sololearn.com/post/47788/?ref=app ");
return 0;
}
2. Lakshay kamat
Made by Lakshay kamat. Simple C Program to Print Fibonacci Series. Source
**********FibonacciSeries********** 0 1 1 2 3
#include <stdio.h>
int main(){
long double input,fibo,n0 = 0,n1 = 1;
scanf("%Lf",&input);
// fibonacci series 0 1 1 2 3 5 8....
// n0 n1
printf("**********FibonacciSeries**********\n");
printf("%.0Lf\n%.0Lf\n",n0,n1);
for (int i = 3; i <=input; i++)
{
fibo = n0 + n1;//0 + 1 = 1
n0 = n1; //0 = 1 , n0 = 1
n1 = fibo;//1 = 1, n1 = 1
printf("%.0Lf\n",fibo); // prints 1
}
return 0;
}
3. By Vijay
Made by Vijay. Fibonacci Series Program. Source
Enter the number of terms: 8 Fibonacci Series: 0, 1, 1, 2, 3, 5, 8, 13,
#include <stdio.h>
int main()
{
int i, n, t1 = 0, t2 = 1, nextTerm;
printf("Enter the number of terms: ");
scanf("%d", &n);
printf("Fibonacci Series:\n");
for (i = 1; i <= n; ++i)
{
printf("%d, ", t1);
nextTerm = t1 + t2;
t1=t2;//added t1=t2
t2=nextTerm;//added t2=nextTerm
}
return 0;
}
4. By Aarti Rani
Made by Aarti Rani. Program that prints first 20 Fibonacci series numbers. Source
Fibonacci Series 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765
#include<stdio.h>
int fib(int n){
if(n==0||n==1)
return n;
return (fib(n-1)+fib(n-2));
}
int main() {
int i;
printf("Fibonacci Series\n");
for(i=0;i<=20;i++)
printf("\n %d",fib(i));
return 0;
}
5. By BroFarOps
Made by BroFarOps. Fibonacci Series Triangle. Source
My Fibonacci Triangle 0 0 1 1 2 3 2 5 8 13 8 21 34 55 89 55 144 233 377 610 987
#include <stdio.h>
#include<stdlib.h>
int main(void){
int b,o,r;
int y= 0, z=1;
printf("Fibonacci Triangle\n\n");
printf("%5d\t\n",y);
for(b=1; b<=5; b++) {
printf(" %4d\t",y);
for (o = 1; o <= b; ++o) {
r = y + z;
printf("%4d\t", r);
y = z;
z = r; }
printf("\n"); } }
6. By Yamin Mansuri
Made by Yamin Mansuri. Source
Enter number of terms : 5 0 1 1 2 3 5
#include <stdio.h>
int main() {
int n,a=-1,b=1,c,i;
printf("Enter number of terms : ");
scanf("%d",&n);
printf("%d\n",n);
for(i=0;i<=n;i++){
c= a+b;
printf("%d ",c);
a=b;
b=c;
}
return 0;
}
7. By Siddhi Jain
Made by Siddhi Jain. Source
3 1 1 2
#include <stdio.h>
int main() {
int a=1,b=1,c;
int d;
scanf("%d",&d);
printf("%d %d",a,b);
printf(" ");
for(int i=0;i<d-2;i++)
{
c=a+b;
a=b;
b=c;
printf ("%d",c);
printf(" ");
}
return 0;
}
8. By BroFar
Another C Fibonacci Series Program by BroFar. Fibonacci Series in bash. Source
Fib in bash 0 + 1 = 1 1 + 1 = 2 1 + 2 = 3 2 + 3 = 5 3 + 5 = 8 5 + 8 = 13 8 + 13 = 21 13 + 21 = 34 21 + 34 = 55 34 + 55 = 89 55 + 89 = 144 89 + 144 = 233 144 + 233 = 377 233 + 377 = 610 377 + 610 = 987 610 + 987 = 1597 987 + 1597 = 2584 1597 + 2584 = 4181 2584 + 4181 = 6765 4181 + 6765 = 10946 6765 + 10946 = 17711 10946 + 17711 = 28657 17711 + 28657 = 46368 28657 + 46368 = 75025 46368 + 75025 = 121393 75025 + 121393 = 196418 121393 + 196418 = 317811 196418 + 317811 = 514229 317811 + 514229 = 832040 514229 + 832040 = 1346269 832040 + 1346269 = 2178309 1346269 + 2178309 = 3524578 2178309 + 3524578 = 5702887 3524578 + 5702887 = 9227465 5702887 + 9227465 = 14930352 9227465 + 14930352 = 24157817 14930352 + 24157817 = 39088169 24157817 + 39088169 = 63245986
#if 0
echo "Fib in bash "
a=$[0]
b=$[1]
for i in {1..75..2}
do
c=$[a + b]
echo "$a + $b = $c"
a=$[b]
b=$[c]
done
: <<'}'
#endif
#include<stdlib.h>
int main() {
system("bash usercode/file0.c");
}