**Fibonacci Series?**

0 1 1 3 5 8 13...

A number generated by adding previous two numbers produces Fibonacci series.

e.g :Here 8th number can be found by adding 6th number and 7th number.

To know more about fibonacii series click here

**Here is the program to find fibonacci series using while loop**

#include<stdio.h>

void main()

{

int a=-1,b=1,fibo=0,i,num;

printf("Enter the range upto Fibonacci Series to be printed: ");

scanf("%d",&num);

for(i=0;i<num;i++)

{

fibo=a+b;

a=b;

b=fibo;

printf("%4d",fibo);

}

}

**Explanation:**

In this program we are running the loop for num times

In loop we have taken

**sum**to store the sum of previous two numbers,then print the number.Thus we get the required series of fibonacci numbers.

**Here is the program to find Nth number in fibonacci series using while loop**

#include<stdio.h>

void main()

{

int a=-1,b=1,fibo=0,i=0,num;

clrscr();

printf("Enter the Nth Fibonacci number to be printed: ");

scanf("%d",&num);

while(i<num)

{

fibo=a+b;

a=b;

b=fibo;

i++;

}

printf("%d number in fibonacci series is %d",num,fibo);

}

**Share your views regarding the given program via the comments section given below.**

**If it was useful to you, please '+1' it & share it on other social networks.**

**Thank You.**

**-Romil shah**

thank u... :) romil good work..

ReplyDeletegood work

ReplyDeleteThank you..

ReplyDeleteyou are welcome

ReplyDeleteThank you bro

ReplyDelete