Premium Essay

Pt1420 Unit 8 Assignment 1: Homework

In:

Submitted By tikki1202
Words 303
Pages 2
Short Answer Review Questions:

6. What is an infinite loop? Write the code for an infinite loop.
An infinite loop is a sequence of instructions in a computer program which loops endlessly.

Example of an infinite loop: Set k = 1 While k < = 5 Display k End While

7. A FOR loop looks like what other loop in a flowchart?
A For loop looks like a count-controlled loop.
8. Why is it critical that accumulator variables are properly initialized?
An accumulator is used to keep a running total of numbers. In a loop, a value is usually added to the current value of the accumulator. If it is not properly initialized, it will not contain the correct total.

9. What is the advantage of using a sentinel?
The advantage of using a sentinel is that when you are processing a long list of values with a loop a sentinel marks the end of a list of items. There is no limit to how many times a loop can execute.

10. Why must the value chosen for use as a sentinel be carefully selected?
The value of a sentinel needs to be carefully selected because it can’t be mistaken as a regular value in the list.
Algorithm Workbench:

3. // Declare a counter variable.
Declare Integer

// Constant for the maximum value
Constant Integer MAX_VALUE = 100

//Display the multiples of 10 from 0 through 100
For counter = 0 to MAX_VALUE Display counter End For

4. //Declare Integer number Declare an accumulator variable

Declare Integer total = 0 Declare Integer counter For counter = 1 to 10 Display “Enter a number.” Input number Set total = total + number End For

Display “The total is”, total

9. Declare Integer count For count < 50 Display “The count is “, count Set count = 1 To 50 End For

10. //Declare integer count
While

Similar Documents

Free Essay

Pt 1420

... Student Name:__________________ Introduction to Programming Winter 2014/2015 Instructor: Martin Remmele Unit 7 Homework Assignment Due by end of first break February 10, 2015 Learning Objectives and Outcomes NOTE: This section lists concepts and techniques to be understood from this unit. The actual assignment that you are to complete is found in the next section: “Assignment Requirements”. * Be able to Use pseudocode/flowcharts to represent repetition structures. * Be able to Create While, Do-While, and Do-Until conditional loops. * Be able to Describe the implications of an infinite loop. Assignment Requirements Complete the following exercises. An exercise that calls for an algorithm may be written in English as a series of steps. An exercise that calls for program statements may be written in a) the text’s pseudocode, b) your own preferred pseudocode notation or c) Visual Basic. (VB code can simply be typed into your Word document; it does not have to be created in the development environment.) The logic of the statements will be more important to the grade than the syntax. * Short Answer Review Questions 1-5, starting on page 213 (5 pts each) * Algorithm Workbench Review Questions 1, 2, 7, and 8, starting on page 213 (10 pts each) * Programming Exercises 1, 3, and 4, starting on page 214 (10 points each) Required Resources * Textbook Submission Requirements ...

Words: 310 - Pages: 2

Premium Essay

Its Making Put Something Here

...PT1420 Introduction to Programming Week-2 Lesson Plan TUE 6:00 PM to 10:30 PM Instructor: Tushar Patel (tspatel02@yahoo.com, tpatel@itt-tech.edu) CLASS: Topic: Unit 2: Software Program Design I Course Objectives Covered by This Unit CO2: Design programs by using flowcharts and pseudo code. CO3: Write programs that perform input, processing, and output. Unit Learning Outcomes LO8: Determine program input, processing, and output stages. LO9: Create the necessary flowcharts to describe a program’s structure. LO10: Use pseudocode to define a program’s structure. LO11: Formulate solution algorithms for calculations by properly following the order of operations. Key Concepts ▪ Determining input, process, and output ▪ Creating flowcharts and pseudocode ▪ Formulating algorithms Reading ▪ Gaddis, Chapter 2: “Introduction to Computers and Programming,” pages 29-55 Resources: • Data Projector • ITT Virtual Library • Text Books • Visual Studio • Lab Computers • Student Removable Hard Drive • VM Ware Player Methods: • Lecture • Group Discussion • Lab Work • Review exercise / Research Papers • Quiz Brief Lesson Overview: Today’s lecture we would be discussing the following topics. • Discuss how all programs basically consist of a three-step process: input, process, and output. Use the payroll calculation program...

Words: 895 - Pages: 4

Premium Essay

Pt1420 1

...Bradley Griffin Keith Warren PT1420 Unit 2 Assignment 1: Homework Short Answer: 1. If the problem is program assignment of some sort, than the first step would be to design the basis of the program in pseudocode to gain a clear picture of what kind of commands will work where, then move into flowcharting to start putting together the logic. b. If the problem is an issue in the code that is preventing it from executing, than the first thing that should be done is to look over the program for syntax errors and logic errors.  2. Pseudocode is fake code. This is where a programmer writes out the code without worry of syntax or logic errors to get a visual feel of how the program should unfold. 3. Input, Process, and Output 4. User-Friendly is a term used to describe programs that are easy to use. Algorithm Workbench: 1. A. Display “Height” B. Input height C. Display “Here is the height you entered:”, height 2. A. Display “Favorite Color” B. Input Favorite Color C. Display “Here is your favorite color you entered:”, color Programming Exercises: 1. Personal Information 1 Display “Name” 2 Input Name 3 Display “Here is the name you have entered:”, name 4 Display “Address with city, state, and ZIP” 5 Input address with city, state, and ZIP 6 Display “This is the address you have entered:”, address with city, state, and ZIP 7 Display “Telephone number” 8 Input telephone number 9 Display “This is the telephone number you have entered:”, telephone ...

Words: 277 - Pages: 2

Premium Essay

Unit 3 Assignment 1: Homework

...Dr. Davis PT1420 26 June 2014 Unit 3 Assignment 1: Homework 5. Write a pseudo code statement that declares the variable cost so that so that it can hold real numbers. a. declare real cost 6. Write a pseudo code statement that declares the variable total so that it can hold integers. Initialize the variable with value zero. a. Declare real price = 0.00 display “the original price” input items original price display “price” 3. Write assignment statements that perform the following operations with variables a, b and c. a. set b = a+2 b. set a = b*4 c. set b = a/3.14 d. set a= b-8 7. Write a pseudo code statement that assigns the value 27 to the variable count. A count: = 27 8. Write pseudo code statement that assigns the sum of 10 and 14 to the variable total. a. declare integer total set total = 10+14 display total 9. Write a pseudo code statement that subtracts the variable down payment from the variable total and assigns the result for the variable due. a. declare integer down payment declare integer total declare integer due set due = total – down payment display “down payment “ input down payment 10. Write a pseudo code statement that multiplies the variable subtotal by 0.15 and assigns the result to the variable total fee a. declare real subtotal declare real totalfee set totalfee subtotal * 0.15 display “subtotal” input subtotal display totalfee 4. Assume the variable result,...

Words: 550 - Pages: 3

Premium Essay

Pt1420

...ALONZO DARGAN (17186943) PT1420 Computer Programming Unit 7 Assignment 1: Homework 7 May 2014 Short Answers Page 213 1-5 1. Why should you indent the statements in the body of a loop? Because by indenting the statements in the body of the loop you visually set them apart from the surrounding code. This makes your program easier to read and debug. 2. Describe the difference between pretest loops and posttest loops. A pretest loop means to test its condition before performing an iteration A posttest loop means it performs an iteration before testing its condition. 3. What is a condition-controlled loop? A condition-controlled loop uses a true/false condition to control the number of times that it repeats. 4. What is a count-controlled loop? A count-controlled loop repeats a specific number of times. 5. What three actions do count-controlled loops typically perform using the counter variable? 1) Initialization: the variable is initialized 2) Test: the loop tests the variable by comparing it to the maximum value 3) Increment: to increase the value during each iteration the loop increments the counter variable by adding 1 to it. Algorithm Workbench Review Questions 1,2,7, and 8 p. 213-214 1. 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 the product contains a value less than 100. A- Declare number as integer ...

Words: 721 - Pages: 3