i need a C program that will dos this Write a recursive func
i need a C program that will dos this
Write a recursive function that multiplies the two integer numbers m times n. Be sure you include comments in your program (document).Solution
#include<stdio.h>
/* function to multiply two numbers x and y*/
int multiply(int x, int y)
{
/* 0 multiplied with anything gives 0 */
if(y == 0)
return 0;
/* Add x one by one */
if(y > 0 )
return (x + multiply(x, y-1));
/* the case where y is negative */
if(y < 0 )
return -multiply(x, -y);
}
/* Main program*/
int main()
{
printf(\"\ %d\", multiply(5, -11));
return 0;
}
OUTPUT:
-55
