Ask Question
27 March, 02:23

Get two positive integers from the user. Write code to multiply the two numbers together using only addition or subtraction. You should not use the '*' operator. Remember that x*y is simply x+x+x + ... + x, y times. You may use eitnher a for loop or a while loop

+3
Answers (1)
  1. 27 March, 02:53
    0
    number1 = int (input ("Enter the first number: "))

    number2 = int (input ("Enter the second number: "))

    result = 0

    for i in range (number1):

    result + = number2

    print (str (result))

    Explanation:

    Ask the user for two numbers

    Initialize result as 0 to hold the multiplication of the numbers

    Create a for loop that iterates "number1" times. In each iteration, add number2 to the result.

    When the loop is done, print the result
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Get two positive integers from the user. Write code to multiply the two numbers together using only addition or subtraction. You should not ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers