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 is a nested formula?
What the different types of arrays in c?
how should functions be apportioned among source files?
Hello. How to write a C program to check and display president party like if i type in the console "biden" and hit enter the output shoud be : "biden is democrat" and if i type "trump" and hit enter the output shoud be: "trump is republican"
Is r written in c?
Is register a keyword in c?
Explain main function in c?
What is structure pointer in c?
What is the difference between array and pointer in c?
What is static and volatile in c?
How many data structures are there in c?
Explain setjmp()?
What are the 3 types of structures?
Why clrscr is used in c?
GIven a sequence of characters. How will you convert the lower case characters to upper case characters. ( Try using bit vector - sol given in the C lib -> typec.h)