Ask Question
29 April, 15:13

Write a while loop that prints usernum divided by 2 (integer division) until reaching 1. follow each number by a space. example output for usernum = 40: 20 10 5 2 1

+1
Answers (1)
  1. 29 April, 17:09
    0
    In the following code snippet,

    N = usernum, which is the input number

    m = round (x) means that the decimal quantity x is rounded to the nearest integer, m

    The symbol # denotes a comment (s) so that everything after the # symbol is ignored as part of the code.

    In a while loop, True is represented by the number 1, and False is represented by the number 0.

    N = inpu ("Enter input number"); # Receive input number

    x = N; # store the input number in the variable x

    while 1 # begin the while loop

    m = round (N/2); # divide x by 2 and round to the nearest integer

    print m; # print the value of m

    print ' '; # print a space

    # If m <=1, break out of the loop

    if m<=1

    break

    end

    end # end of the loop
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a while loop that prints usernum divided by 2 (integer division) until reaching 1. follow each number by a space. example output for ...” in 📙 Mathematics 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