RECURSION

Hi everyone;
I have a question here but i don't understand what it is actually asking.I need to understand this because something similar will be asked in my exams tomorrow. Any explanations and clues will be very much appreciated;
HERE IT IS:-

a)Write down a recursive function that recursively computes and returns the multiplication of two integer parameters.
b)Solve the same question by iterative method.
Here is the solution to a similar problem. You should be able to figure your question out then.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// Recursively sum up the first N positive integers
int sum_first_n_integers( int n ) {
    if( n == 0 )
        return 0;
    else
        return n + sum_first_n_integers( n - 1 );
}

// Iteratively sum up the first N positive integers
it sum_first_n_integers( int n ) {
    int sum = 0;
    for( int i = 1; i <= n; ++i )
        sum += i;
    return sum;
}

yeah thanks.....
Topic archived. No new replies allowed.