Ask Question
19 October, 05:14

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

+4
Answers (1)
  1. 19 October, 08:11
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers