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

void main() { int a[]={1,2,3,4,5},i; for(i=0;i<5;i++) printf("%d",a++); getch(); }

3 Answers  


How variables are declared in c?

0 Answers  


What is false about the following A compound statement is a.A set of simple statments b.Demarcated on either side by curly brackets c.Can be used in place of simple statement d.A C function is not a compound statement.

5 Answers   CCEM, TCS,


A marketing company wishes to construct a decision table to decide how to treat clients according to three characteristics: Gender, City Dweller, and age group: A (under 30), B (between 30 and 60), C (over 60). The company has four products (W, X, Y and Z) to test market. Product W will appeal to female city dwellers. Product X will appeal to young females. Product Y will appeal to Male middle aged shoppers who do not live in cities. Product Z will appeal to all but older females.

2 Answers  


Define Spanning-Tree Protocol (STP)

0 Answers  


What is merge sort in c?

0 Answers  


What are the scope of static variables?

0 Answers  


How to declare a variable?

0 Answers  


Write a program to find the smallest and largest element in a given array in c language

11 Answers   Microsoft, Vembu,


What does extern mean in a function declaration?

4 Answers  


What is a nested formula?

0 Answers  


explain what is a newline escape sequence?

0 Answers  


Categories