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

write a Program to dispaly upto 100 prime numbers(without using Arrays,Pointer)

26 Answers   ADITI, iFlex, Infosys, Oracle, TCS, Unicops, Wipro,


Do you know the difference between malloc() and calloc() function?

0 Answers  


Explain the difference between null pointer and void pointer.

0 Answers   TCS,


in C-programming language without using printf statement can we get output r not ? if yes how and if no also how ?

11 Answers   IBM,


Write a code to remove duplicates in a string.

0 Answers   Expedia,






write the program for maximum of the following numbers? 122,198,290,71,143,325,98

5 Answers  


What does volatile do?

0 Answers  


How do you view the path?

0 Answers  


write a programe to find the factorial of given number using recursion

3 Answers  


What is an array? What the different types of arrays in c?

0 Answers  


C,c++, Java is all are structural oriented or procedure oriented language..?

6 Answers  


main() { char *p1="Name"; char *p2; p2=(char *)malloc(20); while(*p2++=*p1++); printf("%s\n",p2); }

4 Answers   CitiGroup,


Categories