# Unit 7 Assignment 1

Topics: For loop, Addition, Real number Pages: 3 (749 words) Published: November 2, 2014

Unit 7 Assignment 1
Steven Rogusta
ITT Technical Institute
PT1420 Intro to Programming
Misty Kitzul
November 1, 2014
Unit 1 Assignment 1
Why should you indent the statements in the body of a loop? It visually set them apart from the surrounding code, this makes your program easier to read and debug. Describe the difference between pretest loops and posttest loops? Pretest loop or do while loop tests its condition before performing iteration whereas a posttest loop or do until loop executes one or more statements and then a condition is tested. What is condition-controlled loop? Condition-controlled loop uses a true/ false condition to control the number of times that it repeats. What is a count-controlled loop? Count-controlled loop repeats specific number of times. What are three actions do count-controlled loop typically performed using the counter variable? Initialization, Test, Increment

Algorithm Workbench
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. The loop should iterate as long as product contains a value less than 100. //Declare product = 0

Do
Display “Enter a number.”
Input number
Product = number x 10
While product < = 100
Design a Do-While loop that asks the user to enter two numbers. The numbers should be added and the sum displayed. The loop should ask the user if he or she wishes to perform the operation again. If so, the loop should repeat, otherwise it should terminate. Declare 1num as RealDeclare 2num as RealDeclare sumNum as realDoDisplay “What is your first number”Input 1numDisplay “What is your second number”Input 2numsumNum = 1num+2numDisplay “sum num” Convert the While loop in the following code to Do-While loops: Declare Integer x = 1

While x > 0
Display “Enter a number. “
Input x
End While
Declare x as Integer = 1
Do
Display “Enter a number.”
Input x
If x ! = 0 then...