In this tutorial learn how you can write a c program to generate the Fibonacci series up to n terms given by the user.
The Fibonacci numbers are the numbers in the following integer sequence. 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, …….. In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the recurrence relation Fn = Fn-1 + Fn-2. with seed values. F0 = 0 and F1 = 1.
We are using for loop for this tutorial.
C programming is a powerful general-purpose programming language. It can be used to develop software like operating systems, databases, compilers, etc.
Here is the code to generate the Fibonacci series up to n terms given by the user in C programming.
#include <stdio.h> //WAP to generate the Fibonacci series up to n terms given by user int main() { int a = 0, b = 1, c, n, i; printf("Enter n terms for series:"); scanf("%d", &n); for (i = 1; i <= n; i++) { printf("%d\t", a); c = a + b; a = b; b = c; } return 0; }
This is how you can generate the fibonacci series up to n terms given by user in c programming. Comment below if you like our tutorial.