C program for Fibonacci series upto ‘n’ numbers. It is a simple source code that provides the output of an actual Fibonacci sequence up to n numbers. For this C program, questions may asked like “write a C program to find the Fibonacci series & sample Fibonacci program in C“. Take care of a questions for your interviews or students exam. This is a totally free of cost code.
[Related: Sum of Digits of a given number] & [Odd & Even numbers in an Array]
CREATE FIBONACCI SERIES UP TO N NUMBERS IN C
Create a Fibonacci series up to n numbers in C program. It is used to create the Fibonacci series in any particular range of value or up to n terms by looping statement. Basic condition is (cn=2;cn<rge;cn++).
[Read: Career Guidance for all] & [Aptitude Q&A free download]
C CODE:
/* Title: Fibonacci series Author: Vinoth Selvaraj © http://students3k.com */ //Header files #include <stdio.h> #include <conio.h> void main() { //Program variables int cn,rge,num1=0,num2=1,num3; clrscr(); //Function to clear previous output //Display function printf("Enter the range of Fibonacci series to generate : "); scanf("%d",&rge); //Getting input function printf("%d-->%d-->",num1,num2); //Creating fibonacci series. for(cn=2;cn<rge;cn++) //Looping statement { num3=num1+num2; printf("%d-->",num3); num1=num2; num2=num3; } getch(); }