C Program to display the Fibonacci Series up-to n number of terms - wordsclank.in

Saturday, 3 March 2018

C Program to display the Fibonacci Series up-to n number of terms

Before we start coding lets know what exactly Fibonacci Sequence is?
A series of a number in which each number is sum of the two preceding numbers.
For example,  1,1,2,3,5,8,13,21,34,55,89.. is the simplest fibonacci series.

Fibonacci Sequence,Fibonacci Sequence in c

Most related






SOURCE CODE


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#include< stdio.h>

void main()
{
 int i, n, a = 0, b = 1, nxt;
 printf("Enter the number of terms: \n");
 scanf("%d",&n);
 
 printf("The Fibonacci series upto %d term is:\n",n);
 
 for(i = 1; i <= n; i++)
 {
  printf("%d \t",a);
  nxt = a + b;
  a = b;
  b = nxt;
 }
}


OUTPUT

Fibonacci Sequence,Fibonacci Sequence in C

Related Topics




  • C program to store information of n student using structure
  • C program to find the length of a string without strlen( ) function
  • C program to find the Armstrong Number between intervals
  • C program to check whether a certain  number is Armstrong or not
  • C Program to Check Whether a Number is Palindrome or Not
  • C Program to display the Fibonacci Series up-to a certain number
  • C program to find the factorial of a number
  • C Program to Find Prime Numbers Between Intervals Using Functions.
  • C program: perfect or not checking
  • C program to identify a number as even or odd



  • No comments:

    Post a Comment