Courses

Courses

Structure and Union

No Examples found for this topic - CodeHelpPro

Data Files

No Examples found for this topic - CodeHelpPro

Program to find the Fibonacci Series

0 Suresh Chand June 2, 2021

In this example, We will learn a program to find the Fibonacci Series. Before that, You must have knowledge of the following topics

Algorithm

This is the algorithm of program to find fibonacci Series

```Step 1: Start
Step 2: Initialize variables i, n, t1 = 0, t2 = 1
Step 3: Initialize variable and assign t1 + t2
Step 4: Take input from the user and assign to variable n
Step 5: Assign i = 1
Step 6: Repeat this step until i <= n
Step 6.1: Print nextTerm variable
Step 6.2: t1 = t2
Step 6.3: t2 = nextTerm
Step 6.4: nextTerm = t1 + t2
Step 7: End```

Flowchart

This is the flowchart of program to find fibonacci Series

CODE: Program to find the fibonacci Series

We will print fibonacci Series using for loop.

``````#include <stdio.h>

int main() {

int i, n, t1 = 0, t2 = 1;
int nextTerm = t1 + t2;

printf("Enter the number of terms: ");
scanf("%d", &n);
printf("Fibonacci Series: %d\t%d\t", t1, t2);

for (i = 1; i <= n-2; ++i) {
printf("%d\t", nextTerm);
t1 = t2;
t2 = nextTerm;
nextTerm = t1 + t2;
}

return 0;
}``````

The output of above program is

``````Enter number of terms : 10
0       1       1       2       3       5       8       13      21      34``````
Subscribe
Notify of
Inline Feedbacks