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
typedef struct{ char *; nodeptr next; } * nodeptr ; What does nodeptr stand for?
What is the data segment that is followed by c?
How arrays can be passed to a user defined function
write a program which the o/p should b in such a way that s triangle if I/p is 3,a Square/rectangle if I/P=4,a pentagon if I/P=5 and so on...forget about the I/P which is less than 3
What type of function is main ()?
Why should I use standard library functions instead of writing my own?
what is ur strangth & weekness
Why dont c comments nest?
What is file in c language?
What is the difference between local variable and global variable in c?
Write a program with dynamically allocation of variable.
What is the equivalent code of the following statement in WHILE LOOP format?
What is the role of this pointer?
Explain what happens if you free a pointer twice?
What do header files do?