Ask Question

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

+2
Answers (1)
  1. 20 July, 23:21
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers