Programming
Python
R
Java
C
C++
C#
WEB
HTML
CSS
JavaScript
BootStrap4
jQuery
SVG
MORE
Examples1
Python
GO
R
Java
C
C++
C#
Examples2
Python
R
Java
C
C++
C#
HTML
CSS
JavaScript
BootStrap4
jQuery
SVG
Seo Tools
Code Minifier
Code Beautifier
Language Compiler
Misc Tools
File Converter
References
C
C++
Python
Java
PHP
JavaScript
Examples
Python
R
Java
C
C++
C#
HTML
CSS
JavaScript
BootStrap4
jQuery
SVG
Home
About
Contact
JetPack
Multi Themes-->>
Code it ALL
Scroll TOP
C Program to Display Fibonacci Sequence - CodeGK
Δ C Examples
Examples
C "Hello, World!" Program
C Program to Add Two Integers
C Program to Multiply Two Floating-Point Numbers
C Program to Find ASCII Value of a Character
C Program to Compute Quotient and Remainder
C Program to Find the Size of int, float, double and char
C Program to Swap Two Numbers
C Program to Check Whether a Number is Even or Odd
C Program to Check Whether a Character is a Vowel or Consonant
C Program to Find the Largest Number Among 3 Numbers
C Program to Find the Largest Number Among 3 Numbers
C Program to Find Square root of a number
C Program to Find the Roots of a Quadratic Equation
C Program to Check Leap Year
C Program to Check Whether a Number is Positive or Negative
C Program to Check Whether a Character is an Alphabet or non-Alphabet
C Program to Calculate the Sum of N Natural Numbers
C Program to Find Factorial of a Number
C Program to Generate Multiplication Table
C Program to Display Fibonacci Sequence
C Program to Find GCD of two Numbers
C Program to Find LCM of two Numbers
C Program to Count Number of Digits in an Integer
C Program to Reverse a Number
C Program to Calculate the Power of a Number
C Program to Check Whether a Number is Palindrome or Not
C Program to Check Whether a Number is Prime or Not
C Program to Display Factors of a Number
♦ C Program to Display Fibonacci Sequence
♣ Example1: C Program to Display Fibonacci Sequence
Input:
Run CODE
Reload Code
Copy Code
#include
#include
// The function below generates n numbers in Fibonacci series void showFibonacci(int number){ int num0=0; int num1=1; for(int i=1; i<=number; i++){ if(i==1){ printf("%d ",num1); } if(i>=2){ int temp=num1; num1=num1+num0; printf("%d ",num1); num0=temp; } } puts("\n"); } int main() { int number1=5; showFibonacci(number1); int number2=8; showFibonacci(number2); int number3=12; showFibonacci(number3); return 0; }
Output: