multiplecation using addition

August 29, 2011 at 13:24:23
Specs: Windows XP
Write an algorithm that takes two numbers and calculates the
product of the numbers using the binary operator '+' only i.e. the
algorithm should NOT use the binary operator 'x'.

See More: multiplecation using addition

Report •

#1
August 29, 2011 at 19:22:11
multiplication is akin to repeated addition. For example if there are 5 groups of 3 items then.

3 + 3 + 3 + 3 + 3 = 15

HTH


Report •

#2
September 5, 2011 at 14:23:47
I found the error sorry for the late post but i will still share the solution in case someone may need to see it to help them with something

Dont worry i found the error solution is below

<html>
<head>
<title>
Calculator
</title>
<script type="text/javaScript">


<!-- Begin
function doMath() {
var one = eval(document.theForm.elements[0].value);
var two = eval(document.theForm.elements[1].value);
var prod=0;

for (var i=0; i<two; i++)
{
prod = prod + one;
}
alert("The product of " + one + " and " +
two + " is " + prod + ".")
}
// End -->
</script>

</head>

<body>

<CENTER>
<FORM NAME="theForm">
Multiply
<INPUT TYPE="text">
By
<INPUT TYPE="text">
<INPUT TYPE="button" VALUE="Show result" onClick="doMath()">
</FORM>
</CENTER>

</body>
</html>


Report •
Related Solutions


Ask Question