wtite a program that will multiply two integers in recursion
function
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
void main() { int a[]={1,2,3,4,5},i; for(i=0;i<5;i++) printf("%d",a++); getch(); }
How variables are declared in c?
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.
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.
Define Spanning-Tree Protocol (STP)
What is merge sort in c?
What are the scope of static variables?
How to declare a variable?
Write a program to find the smallest and largest element in a given array in c language
What does extern mean in a function declaration?
What is a nested formula?
explain what is a newline escape sequence?