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 are shell structures used for?
What is ## preprocessor operator in c?
difference between native and cross compilers
What is the difference between struct and typedef struct in c?
Write a program to print fibonacci series using recursion?
What is external variable in c?
Write a C program to help a HiFi’s Restaurant automate its breakfast billing system. Your assignment should implement the following items: a. Show the customer the different breakfast items offered by the HiFi’s Restaurant. b. Allow the customer to select more than one item from the menu. c. Calculate and print the bill to the customer. d. Produce a report to present your complete program and show more sample output. Assume that the HiFi’s Restaurant offers the following breakfast menu: Plain Egg $2.50 Bacon and Egg $3.45 Muffin $2.20 French Toast $2.95 Fruit Basket $3.45 Cereal $0.70 Coffee $1.50 Tea $1.80
Differentiate between ordinary variable and pointer in c.
What is a list in c?
Explain the process of converting a Tree into a Binary Tree.
Define circular linked list.
What is #include cctype?
Can a variable be both static and volatile in c?
What does c mean?
What does malloc () calloc () realloc () free () do?