Ask Question

Assume there are two variables, k and m, each already associated with a positive integer value and further assume that k's value is smaller than m's. Write the code necessary to compute the number of perfect squares between k and m. (A perfect square is an integer like 9, 16, 25, 36 that is equal to the square of another integer (in this case 3*3, 4*4, 5*5, 6*6 respectively).) Associate the number you compute with the variable q. For example, if k and m had the values 10 and 40 respectively, you would assign 3 to q because between 10 and 40 there are these perfect squares: 16, 25, and 36,.

+2
Answers (1)
  1. 19 July, 23:04
    0
    The correct answer of the given question is:

    The following code is written in python.

    i = 1

    q = 0

    while i * i < k:

    i + = 1

    while i * i < = m:

    q + = 1

    i + = 1

    Explanation:

    Firstly we have two variables which is "k" and the second one is "m" and they have a positive integer value

    If we discuss about to our code then, we take a variable "i" and value assign to it is "1" and then we take another variable "q" and value assign to it is "0", as per the question we check the condition of the variable "k" and then "m".
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Assume there are two variables, k and m, each already associated with a positive integer value and further assume that k's value is smaller ...” 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