Animal Names and Sounds APplication for Kids

Animal Names and Sounds APplication for Kids
Click on above image to see application

Write a Program to generate Fibonacci Series in C

The first two Fibonacci numbers are 0 and 1 then next number is addition of previous two numbers.
0, 1, 1, 2, 3, 5, 8, 13, 21
Fibonacci number Nth can be calculated as the formular follows:


Using Recursive Method:

int fibonacci(int num)
{
         if(num==0)
                return 0;
         if(num==1)
                return 1;
         return fibonacci(num-1)+fibonacci(num-2);
}

Using Iterative Method:

int fibonacci(int num)
{
          int f1=0;
          int f2=1;
          int fn;
          for(int i=2;i<n;i++)
          {
                fn=f1+f2;
                f1=f2;
                f2=fn;
          }
}

2 comments:

  1. Hey admin,
    of course this blog is doing a very good job of serving useful information. I'm proud to be a part of its Readers community.
    for more programing visit my web
    http://www.hhhprogram.com/

    ReplyDelete
    Replies
    1. hey admin....
      this is a very useful answer....but i want to know how to get the output get printed in a listview in android eclipse

      Delete