This code is shared by

Fibonacci number

In mathematics, the Fibonacci numbers are the numbers in the following integer sequence:

1, 1, 2, 3, 5, 8, 13, 21, 34,55,89,144,...

A Fibonaccispiral created by drawing arcs connecting the opposite corners of squares in the Fibonacci tiling; this one uses squares of sizes

By definition, the first two Fibonacci numbers are 0 and 1, and each subsequent number is the sum of the previous two.

Enter the limit:

5

1

2

3

5

8

The 5th Fibonacci number is 8

**Shweta Jhunjhunwala**, thanks for your contribution.**Share your C, C++,C# program with us we will post them here..**Fibonacci number

In mathematics, the Fibonacci numbers are the numbers in the following integer sequence:

1, 1, 2, 3, 5, 8, 13, 21, 34,55,89,144,...

A Fibonaccispiral created by drawing arcs connecting the opposite corners of squares in the Fibonacci tiling; this one uses squares of sizes

By definition, the first two Fibonacci numbers are 0 and 1, and each subsequent number is the sum of the previous two.

**Sample Output:**Enter the limit:

5

1

2

3

5

8

The 5th Fibonacci number is 8

**Code:**/*program for fibonacci series using functions*/

#include<stdio.h>

#include<conio.h>

void main()

{

int n;

long int i;

long int fibo(int n);

clrscr();

printf("Enter the limit:\n");

scanf("%d",&n);

i=fibo(n);

printf("\nThe %dth Fibonacci number is %ld",n,i);

getch();

}

long int fibo(int n)

{

int old_no,currnt_no,sum,i;

i=1;

old_no=0;

currnt_no=1;

while(i<=n)

{

sum=old_no+currnt_no;

old_no=currnt_no;

currnt_no=sum;

i++;

printf("\n%d",sum);

}

return(sum);

}

#include<stdio.h>

#include<conio.h>

void main()

{

int n;

long int i;

long int fibo(int n);

clrscr();

printf("Enter the limit:\n");

scanf("%d",&n);

i=fibo(n);

printf("\nThe %dth Fibonacci number is %ld",n,i);

getch();

}

long int fibo(int n)

{

int old_no,currnt_no,sum,i;

i=1;

old_no=0;

currnt_no=1;

while(i<=n)

{

sum=old_no+currnt_no;

old_no=currnt_no;

currnt_no=sum;

i++;

printf("\n%d",sum);

}

return(sum);

}

**Hope you liked the posts, give comments if you have any doubts.. :)**

## 2 comments:

Dear sir , one doubt . 5 th number of the fibonacci series is 5. How u say the 5 th num in the fibonacci series is 8. That step i doubt. If my doubt is wrong or mistake , sorry for the distapt

good program thank you for sharing

## Post a Comment