wtite a program that will multiply two integers in recursion
function

Answers were Sorted based on User's Feedback



wtite a program that will multiply two integers in recursion function..

Answer / 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

wtite a program that will multiply two integers in recursion function..

Answer / mohit taneja

int mul(int n)
{
static int num;
printf("enter the number");
scanf("%d",&num);
if(n==1)
{
return num;
}
else
{
num=num*mul(n-1);
}
return num;
}

void main()
{
int n,result;
printf("enter the number of digit u want to multiply");
scanf("%d",&n);
int result=mul(n);
printf("multiplication=%d",result);
getch();
}

Is This Answer Correct ?    13 Yes 22 No

wtite a program that will multiply two integers in recursion function..

Answer / der

#include<iostream.h>
void main()
{clrscr();
int x,y,sum;
sum=x+y;
cout<<sum;
getch();
}

Is This Answer Correct ?    0 Yes 9 No

wtite a program that will multiply two integers in recursion function..

Answer / matloob

void main()
{
int a,b,c;
c=a*b;
getch
}

Is This Answer Correct ?    3 Yes 17 No

Post New Answer

More C Interview Questions

Can a variable be both static and volatile in c?

0 Answers  


c program to manipulate x=1!+2!+3!+...+n! using recursion

1 Answers   TCS,


In scanf h is used for

4 Answers   BFL,


What is a macro, and explain how do you use it?

0 Answers  


What is difference between array and structure in c?

0 Answers  






Consider the following C program. #include <stdio.h> int main() { int i; for (i=0;i<3;++i) { fork();fork(); } } How many processes are created when running this program (including the initial one)? Explain

2 Answers  


What is the memory allocated by the following definition ? int (*x)();

2 Answers   ADITI,


What are Storage Classes in C ?

32 Answers   CTS, HP, IBM, Maharaja Whiteline, Tamil Nadu Open University TNOU, TATA, TCS, Wipro,


Explain argument and its types.

0 Answers  


Should I use symbolic names like true and false for boolean constants, or plain 1 and 0?

0 Answers  


Why is structure padding done in c?

0 Answers  


What is a newline escape sequence?

0 Answers  


Categories