Learn about C Program to Find Fibonacci Series in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.
Contents
C Program to Find Fibonacci Series
Program:
#include<stdio.h>
int main()
{
int a=0, b=1, num, c;
printf("Enter number of terms: ");
scanf("%d",&num);
for(int i=0; i<num; i++)
{
printf("%d\t",a);
c = a + b;
a = b;
b = c;
}
return 0;
}
Output:
Enter number of terms: 8
0 1 1 2 3 5 8 13
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Codes :
Sum of series in C language 1 + 1/(2*2) + 1/(3*3) + 1/(4*4) + ….. + 1/(n*n) using pow() Function
Sum of series in C language 1 + 1/(2*2) + 1/(3*3) + 1/(4*4) + ….. + 1/(n*n) using while loop