C Program to Generate Fibonacci Series

In this program, you’ll learn C Program to Generate Fibonacci Series. Write a C Program to Generate Fibonacci Series.

#include<stdio.h>
#include<conio.h>
void main()
{
 int n, f,s,new;
clrscr();
printf("Enter the final term of the series:");
scanf("%d",&n);
f=0;
s=1;
printf("%6d%6d",f,s);
new=f+s;
while(new<=n)
{
printf("%6d",new);
f=s;
s=new;
new=f+s;
}
getch();
}

Output :
Enter the final term of the series: 8
0  1  1  2  3  5  8

Recommended Posts:

C
    1. Fundamental of C Language
    2. Keywords in C
    3. Data Types in C
    4. Operators in C
    5. Type Conversion in C
    6. Input/Output Functions in C
    7. C Program to Swap Two Numbers With or Without Temporary Variables
    8. Control Statements in C – if, else, switch
    9. Loop Control Statements in C | for, while, do-while loop
    10. Comparison Between for loop while loop and do-while loop
    11. Unconditional Control Transfer Statements in C
    12. C Program to Check Armstrong Number
    13. C Program to Generate Fibonacci Series
    14. C Program to Check Whether a Number is Prime or Not
    15. C Program to Convert Binary Number to Decimal
    16. C Program to Convert Decimal Number to Binary