1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
son4ous [18]
3 years ago
9

Given the following code fragment, how many times does the loop body execute? int laps = 50; int myNum = 1; do { myNum = myNum +

2; laps = laps + 1; } while(laps <= 1);
Computers and Technology
1 answer:
Jlenok [28]3 years ago
8 0

Answer:

one

Explanation:

The loop is used to execute the part of code or statement again and again until the condition is not FALSE.

There are three types of loop in programming.

1. for loop

2.while loop

3. do-while loop

Do-while has one special property which makes it different from other loops.

The loop statement executes once if the condition of the loop is failed in the starting.

In do-while, the statement executes first and then while checking the condition.

let discuss the code:

initially, laps=50, myNum=1

then, the program executes the statement in the loop.

so, myNum = 1 + 2=3.

A value 3 is assign to the variable myNum.

laps = 50 + 1=51.

A value 3 is assigned to the laps variable.

then while checking the condition (51 <= 1) which is FALSE.

The program terminates the loop.

Therefore, the answer is one.

You might be interested in
How do you keep word from trying to capitalize every isolated letter "i"
Firdavs [7]
Write "i" the write random words then delete it and add the lowercase i
8 0
3 years ago
Read 2 more answers
Package Newton’s method for approximating square roots (Case Study 3.6) in a function named newton. This function expects the in
notka56 [123]

Answer:

import math

#Initialize tolerance

tolerance = 0.000001

def newton(x):

   """ Returns the square root of x """

   #Performs the successive approximations

   estimate = 1.0

   while True:

       estimate = (estimate + x / estimate) / 2

       difference = abs(x - estimate ** 2)

       if difference <= tolerance:     # Break out of loop if difference is less than tolerance

           break            

       return estimate     # While the difference value is > TOLERANCE, the process continues

def main():

   """Allows the user to obtain square roots."""

   while True:

       #Receive the input number from the user

       x = input("Enter a positive number or enter/return to quit: ")

       if x == "":     #if user presses "Enter" then exit the program

           break       # Otherwise, continue the process of allowing new numbers

       x = float(x)

       #Output the result

       print("The programs estimate of the square root of ", x, "is ", round(newton(x),2))

       print("Python's estimate: ", math.sqrt(x))

main()

8 0
3 years ago
A series of drawn pictures (like a comic) of key visual shots of planned production for video is a/an
Ne4ueva [31]

Answer:

The correct answer is <u>D) Storyboard</u>

Explanation:

A storyboard is used during the initial planning stage of filmmaking. You draw pictures to demonstrate the general idea of what shots you want to get before actually going out and filming on a set/studio.

4 0
3 years ago
When computing effect size, the sample size is ________.
NNADVOKAT [17]
Sample size  is not taken into account

8 0
3 years ago
According to Darwin’s theory of evolution, differences between species may be a result of which of the following?
ArbitrLikvidat [17]

Explanation:

Your answer is C natural selection.

8 0
3 years ago
Read 2 more answers
Other questions:
  • F we are reduced to a set of computer algorithms, how do we differentiate ourselves from our programming or our connectome? is i
    8·1 answer
  • Give the type and value of each result of the following Java expressions.
    14·1 answer
  • _____ provides vital protection and maintenance services for system hardware and software, including enterprise computing system
    12·1 answer
  • The following checksum formula is widely used by banks and credit card companies to validate legal account numbers: d0 + f(d1) +
    13·1 answer
  • Write a function maxTemp which takes a filename as string argument and returns the maximum temperature as float type for the wee
    13·1 answer
  • In C#Write the program SubscriptExceptionTest in which you use an array of 10 doubles. Write a try block in which you place a lo
    5·1 answer
  • PLEASE HELP I FAILED TWICE AND HAVE ONLY ONE MORE TRY BEFORE MY GRADE ARE SET I AM CRYINGGGGG PLEASEEE IM BEGGINGGGGG
    10·1 answer
  • How was kapilvastu named​
    11·1 answer
  • Simple example of hybrid computer​
    7·2 answers
  • you're troubleshooting an ip addressing issue, and you issue a command to view the system's tcp/ip configuration. the command yo
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!