answersLogoWhite

0

The only reason to use a "while" loop is to reject invalid data. In pseudocode, it is something like this:

do {

(ask for number - store to variable "x")

} while ("x" is invalid)

The details within parentheses will depend on the programming language. The condition for the "while" also depends on the condition you want to fulfill; for example, you might reject a number that is negative or zero. Note that this uses a "while" that is evaluated at the end; in this case, the loop is executed at least once. If the condition is more complicated to evaluate - for example, the data is input as text and you need to reject non-numeric input - you can do additional processing within the loop, and set a variable "valid" that will be true if the input is valid. In that case, the last line will simply change to:

... while (!valid)

User Avatar

Wiki User

11y ago

What else can I help you with?

Continue Learning about Engineering

Design a while loop that lets the user enter a number the number should be multiplied by 10 and the result stored in a variable named product?

Define number_in, product integer; Set product = 0; While product < 100 set product = number_in * 10; accept (input) number_in End_while


How do you enter a number as octal in c?

Not sure is what respect, but when you want a variable to be read as an octal put a 0 in front of the number. a = 01, b = 02; Lets the compiler know that 1 and 2 are to be stored as octals. To print an unsigned number as an octal use %o.


Can identify the odd and the even in the java script using HTML?

Here is a JavaScript option for determining if a number is odd or even. It even lets you know if the number is zero (if you want zero to be neither odd nor even). var n = prompt("Enter a number to identify as odd or even", "Type your number here"); n = parseInt(n); if (isNaN(n)) { alert("Please Enter a Number"); } else if (n == 0) { alert("The number is zero"); } else if (n%2) { alert("The number is odd"); } else { alert("The number is even"); }


What is neither inside the house nor outside the house but lets you see both?

The answer to this riddle is a window. A window is a structure that is neither fully inside the house nor outside, as it serves as a barrier between the two. It allows light to enter and provides a view of the outside while remaining part of the home's architecture.


What skills do you need to be an airplane engineer at Boeing?

You need to know how to design airplanes. To learn this you get a degree in aerospace engineering.And when you DO get this degree and go to work for Boeing, you will quickly learn that airplanes, especially transport-category aircraft like Boeing makes, are so complex there's no way one person could design an entire airplane. They specialize--there's a team of engineers who do nothing but design the various ports and doors the ground crew uses when they work on a plane. If the ground crew can service an airplane fifteen minutes faster, that gives the passenger service agents fifteen more minutes to load the plane while maintaining the same schedule which makes the passengers happier, or it lets the plane leave fifteen minutes quicker which lets the airline make more money.

Related Questions

Design a while loop that lets the user enter a number?

#declare value of product product = 0 #while loop in python #while (test condition) : # statements (s) while product < 100: #prompt for a user to enter a number n1 = input ("Enter a number: ") #multiply n1 times 10 product = n1 * 10


Design a while loop that lets the user enter a number the number should be multiplied by 10 and the result stored in a variable named product?

Define number_in, product integer; Set product = 0; While product < 100 set product = number_in * 10; accept (input) number_in End_while


What button lets you copy text into a cell instead of inserting the next higher number?

You can type whatever you want into a cell. You do not have to enter numbers.


What process lets food enter the cells of an organism?

Absorption


When can you enter the park in lets ride friends forever?

I own lets ride, friends forever and I've played about 100 times, but I can't enter the park! I don't think you can.


Is there a website that lets you design your own rubik's cube then buy it and have it delivered to you?

no


Where can you get a program that lets you design your own Pokemon game from a Rom?

Yes


How do I contact my local army recruiter?

This U.S. Army website lets you enter your zip code and get the address and phone number of a recruiter near you: http://www.goarmy.com/contact/find_a_recruiter.jsp


Where can I find plans or designs for decks and porches?

There is an "interactive CD ROM" that lets you design your decks and porches and you can purchase them from DecksUSA, which is an online website. They ahve a phone number where you can call them and and ask questions about the CD and how you can design your own deck and porch.


What structure lets certain things enter and leave in animal cell?

Mitochondria


Any hardware component that lets you enter data?

do your own test, idiot.


What in a plant cell lets things enter and leave the nucleus?

The nuclear membrane.