Monday, 7 March 2016

C Program to Display Fibonacci Series Using While Loop

Problem :- Write A C Program to Display Fibonacci Series Using While Loop .

Logic :- For Print Fibonacci Series We Use Simple Method .As we know that Fibonacci Series is start with Zero (0) and next Element is One Then we add previous two element and print next element of Fibonacci Series .

Example :- Fibonacci Series is up-to 10 Element is below 

Fibonacci Series :- 0 ,1 ,1 ,2 ,3 ,5 ,8 ,13 ,21 ,34 .

Explanation :- Fibonacci Series start with Zero and next element is one then first we print 0 and 1.
Now add two previous element and print then next element is 0+1=1.
repeat that process 
1+1=2
1+2=3
2+3=5
3+5=8
5+8=13
8+13=21
13+21=34

Done.

Try Yourself C++ Program To Find Large Fibonacci Series

Solution :-

#include<stdio.h>
int main()
{
  //ghanendra yadav 
  int count, n, t1=0, t2=1, Temp=0;
  
  printf("Enter The Number of Terms :\n");
  scanf("%d",&n);
  
  printf("\nFibonacci Series : %d , %d , ", t1, t2);
  count=2;  
  while (count<n)  
{
      Temp=t1+t2;
      t1=t2;
      t2=Temp;
      ++count;
      printf("%d , ",Temp);
  }
  return 0;
}

Output:-


C Program to Display Fibonacci Series Using While Loop

Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date. If you have any Query or Question you can ask in the group, I will Try To Solve your Query and try to answers of your Questions withing 24 Hours, You can also Email me or comment below Please suggest to your Friends to join and like our page and don't forget to Subscribe. Enter your Email and click to subscribe.

Ghanendra Yadav

Ghanendra Yadav

Hello, I Am Ghanendra Yadav Owner of This Blog, I am professional Blogger and Programmer. I Love Programming, Logo Making, And Banner Designing. My Highest Qualification is MCA From NIT Warangal. You Can Find Me On Social Media Through Below Link And If You Have Any Query Related To Programming And Other Subject Comment Below or You Can Mail Me I Will Try To Answer Within 24 Hours Email:- yghanendra@student.nitw.ac.in

Find me on Social Media

Facebook | Twitter | Google+ | RSS Feed

No comments:

Post a Comment