Write an algorithm that calculates A*B without multiplication (A and B are integers) in laguage C
Answers
Answered by
0
Answer:
4 * 5 = 20
How it works?
4 added 5 times
(4 + 4 + 4 + 4 + 4) = 20
Explanation:
//Multiplication of two numbers
#include <stdio.h>
int main()
{
int x, y; //declaring two integer variable
int product = 0; //initializing product to zero
printf("Enter two integers:\n");
scanf("%d%d", &x, &y);
//loop to calculate product
while(y != 0)
{
product += x;
y--;
}
printf("\nProuduct = %d\n", product);
return 0;
}
Similar questions