#include <stdio.h>
#include <conio.h>

void main()
{
    int m;
    int n;
    int multi;

    printf("enter value : ");
    scanf ("%d", &m);

    printf("enter value of multiply : ");
    scanf ("%d", &n);

    multi = multiply(m,n);

    printf("the value of multiply : %d", multi);

}



int multiply (int m, int n)
{
    if (n == 1)
        return m;
    else
        return m + multiply(m,n-1);
}

hi,
im doing coding about recursive, im not sure its recursive or not.
can someone have a look at it.
thank you

A recursive function is a function that repeatedly calls itself. A valid recursive function must have at least one base case (a valid way to exit) or it could go into an infinite loop. However, if a recursive function does not cover all possible base cases, the function can still go into an infinite loop.

Now, look at your main() and multiply(int, int) functions. Is any of those functions matched what I said earlier? If so, then you have a recursive function. :)

If you ask me whether the function has limitation, then my answer is yes. You function will go into an infinite loop when n<=0.

thank you so that explaination
help me a lot =) taywin

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.