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
What does node * mean?
What is the advantage of an array over individual variables?
What is int main () in c?
What are pointers really good for, anyway?
What are near, far and huge pointers?
How can I list all of the predefined identifiers?
Write a program to print numbers from 1 to 100 without using loop in c?
What is the condition that is applied with ?: Operator?
In c language can we compile a program without main() function?
What is scanf () in c?
What is printf () in c?
What is the difference between break and continue?
How do you construct an increment statement or decrement statement in C?
Why cant I open a file by its explicit path?
if p is a string contained in a string?