wtite a program that will multiply two integers in recursion
function

Answer Posted / shruthi.k.a

multiplication of two numbers say 2*3 is similar to adding
the first number the second number of times(i.e in our
example 2+2+2 will give 2*3)
hence,


int add(int m,int n)
{
static int res;
if(n==1)
return m;
else
res=m+add(m,n);
printf("%d\n",res);
return ;
}

int main()
{
int m,n;
printf("enter the two numbers\n");
scanf("%d%d",&m,&n);
add(m,n);
return 0;
}

Is This Answer Correct ?    16 Yes 17 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does node * mean?

702


What is the advantage of an array over individual variables?

728


What is int main () in c?

617


What are pointers really good for, anyway?

606


What are near, far and huge pointers?

639






How can I list all of the predefined identifiers?

569


Write a program to print numbers from 1 to 100 without using loop in c?

629


What is the condition that is applied with ?: Operator?

654


In c language can we compile a program without main() function?

567


What is scanf () in c?

655


What is printf () in c?

574


What is the difference between break and continue?

598


How do you construct an increment statement or decrement statement in C?

731


Why cant I open a file by its explicit path?

587


if p is a string contained in a string?

1398