PLEASE HELP AS SOON AS POSSIBL

Aug 26, 2014 at 9:28pm
prepare a c++ program which will compute Fibonacci numbers. the resulting answer must be of unsigned long
The input is the position of the requested number in the sequence of Fibonacci numbers.
turn in two versions of your program, one based on iteration (loop)and the other on recursion.

in addition to listing of the two version, please answer:
With your development platforms, what is the range of values allowed for unsigned long?
list input you testing?
if your resulting answer were specified to be of type int, would your test data set change? if so, what changes would you make and why?
Last edited on Aug 26, 2014 at 10:11pm
Aug 26, 2014 at 9:33pm
We do not provide homework solutions. Please try your best and ask a specific question when you get stuck.
Aug 26, 2014 at 9:37pm
I do not understand what is the different between if use loop or recursion.
Aug 26, 2014 at 9:40pm
I used Microsoft Visual c++ 2010 express
is it ok or there is another program better.
Aug 26, 2014 at 9:44pm
I do not understand what is the different between if use loop or recursion.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>

void recursion(int x);
void loop(int x);

int main()
{
    recursion(10);
    loop(10);
    
    return 0;
}


void recursion(int x)
{
    if(x > 0)
    {
        std::cout << "This is recursion. x = " << x << std::endl;
        return recursion(x - 1);
    }
}

void loop(int x)
{
    for(int i = 0; i < x; ++i)
        std::cout << "This is a loop! i = " << i << std::endl;
}
This is recursion. x = 10
This is recursion. x = 9
This is recursion. x = 8
This is recursion. x = 7
This is recursion. x = 6
This is recursion. x = 5
This is recursion. x = 4
This is recursion. x = 3
This is recursion. x = 2
This is recursion. x = 1
This is recursion. x = 0
This is a loop! i = 0
This is a loop! i = 1
This is a loop! i = 2
This is a loop! i = 3
This is a loop! i = 4
This is a loop! i = 5
This is a loop! i = 6
This is a loop! i = 7
This is a loop! i = 8
This is a loop! i = 9
Last edited on Aug 26, 2014 at 9:47pm
Aug 27, 2014 at 8:02pm
i don't either
Topic archived. No new replies allowed.