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 is a nested formula?

609


What the different types of arrays in c?

618


how should functions be apportioned among source files?

628


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"

1584


Is r written in c?

730






Is register a keyword in c?

639


Explain main function in c?

630


What is structure pointer in c?

577


What is the difference between array and pointer in c?

582


What is static and volatile in c?

785


How many data structures are there in c?

620


Explain setjmp()?

661


What are the 3 types of structures?

574


Why clrscr is used in c?

591


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)

688