Ask Question
27 August, 04:55

Assume you want to write a code to calculate the addition of two numbers digit by digit. Provide the running time for your algorithm, assuming the inputs are two n-digit numbers. Explain your answer

+1
Answers (1)
  1. 27 August, 06:24
    0
    Using Python programming language

    Explanation:

    1. I defined a function add and passed in two parameters (a, b).

    2. In the block of the function, I added the two numbers and printed the result.

    3. I decided to use a function so that the program is re-usable and can accept various inputs.

    Find the code below. (# are used for comments)

    #Addition of numbers

    def add (a, b):

    print (a+b)

    #Test Cases

    add (2,4.5) #Result=6.5

    add (10,290) #Result=300

    add (2.567,4.58) #Result=7.147
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Assume you want to write a code to calculate the addition of two numbers digit by digit. Provide the running time for your algorithm, ...” 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