#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;
        return m + multiply(m,n-1);

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

2 Years
Discussion Span
Last Post by Izzah_2

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.

Edited by Taywin

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.