03-1-HO-Loops Hand Out
Total Page:16
File Type:pdf, Size:1020Kb
1 of 1 03-1-HO-Loops Hand out
Along with sequences and decisions, loops are an important construct in programming.
In the programs that were written before, the program requested the user enter 2 numbers then select from a menu of choices. The program then ended. If the person required 2 more numbers to be worked on then the program has to be executed again.
Most programs want to do processing over and over again until a decision to stop is reached. This requires a loop and a condition for looping. Here is a sample and simple program.
Write a program that Asks for 2 numbers called n1 and n2 Displays the two numbers and the total on one line but does NOT use a total variable Displays how many times you have been in the loop It continues until the user decides to stop the program
03-1-HO-Loops Hand out
Along with sequences and decisions, loops are an important construct in programming.
In the programs that were written before, the program requested the user enter 2 numbers then select from a menu of choices. The program then ended. If the person required 2 more numbers to be worked on then the program has to be executed again.
Most programs want to do processing over and over again until a decision to stop is reached. This requires a loop and a condition for looping. Here is a sample and simple program.
Write a program that Asks for 2 numbers called n1 and n2 Displays the two numbers and the total on one line but does NOT use a total variable Displays how many times you have been in the loop It continues until the user decides to stop the program
0dcbe0c83fa8f231b2b44c10725b6376.doc by rt -- 4/4/2018 1 of 1