Which structure causes a statement or set of statements to execute repeatedly quizlet?
Terms in this set (22)Sets with similar termsSets found in the same folderOther sets by this creatorVerified questions
COMPUTER SCIENCE Verified answer
COMPUTER SCIENCE Write an algorithm to read in a sequence of values $\mathrm {v} \geq 0$ one at a time, and determine if the list contains at least one adjacent pair of values that are identical. The end of the entire list is marked by the special value V = −1. For example, if you were given the following input: 14, 3, 7, 7, 9, 1, 804, 22, −1, the output of your algorithm should be a ‘Yes’ because there is at least one pair of adjacent numbers that are equal (the 7s). However, given the following input: 14, 3, 7, 77, 9, 1, 804, 22, −1, the output of your algorithm should be a ‘No’ because there are no adjacent pairs that are equal. You may assume in your solution that there are at least two numbers in the list. Verified answer COMPUTER SCIENCE Verified answer
COMPUTER SCIENCE Verified answer Recommended textbook solutions
Other Quizlet setsRelated questions
Home Subjects Expert solutions Create Log in Sign up Upgrade to remove ads Only SGD 41.99/year
Terms in this set (36)Repetition structure More commonly known as a loop, a repetition structure causes a statement or set of statements to execute repeatedly as many times as necessary. Condition-controlled loop A
condition-controlled loop causes a statement or set of statements to repeat as long as a condition is true. In Python you use the "while" statement to write a condition-controlled loop. Count-controlled loop A count-controlled loop iterates a specific number of times. In Python you use the "for" statement to write a count-controlled loop. The for statement is designed to work with a sequence of data items. When the statement executes, it iterates once for each item in the sequence. Loop iteration Each execution of the body of a loop. Does the while loop test its condition before or after it performs an iteration? Before; What is an accumulator? The variable used to keep the running total is called an accumulator. Should an accumulator be initialized to any specific value? Why or why not? Yes, to 0. What is a sentinel? A sentinel is a special value that marks the end of a sequence of values. Why should you take care to choose a distinctive value as a sentinel? A sentinel value must be distinctive enough that it will not be mistaken as a regular value in the sequence. What does the phrase "garbage in, garbage out" mean? GIGO; refers to the fact that computers cannot tell the difference between good data and bad data. If a user provides bad data as input to a program, the program will process that bad data and, as a result,
will produce bad data as output. Give a general description of the input validation process. Input validation is the process of inspecting data that has been input to a program, to make sure it is valid before it is used in a computation. Describe the steps that are generally taken when an input validation loop is used to validate data. Get input What is a priming read? What is its purpose? The first input operation-just before the loop-is called a priming read, and its purpose is to get the first input value that will be tested by the validation loop. If the input that is read by the priming read is valid, how many times will the input validation loop iterate? None A _______-controlled loop uses a true/false condition to control the number of times that it repeats. condition A _______-controlled loop repeats a specific number of times. count Each repetition of a loop is known as a(n) _______. iteration The while loop is a _______ type of loop. pretest A(n) _______ loop has no way of ending and repeats until the program is interrupted. infinite The -=
operator is an example of a(n) _______ operator. augmented assignment A(n) _______ variable keeps a running total. accumulator A(n) _______ is a special value that signals when
there are no more items from a list of items to be processed. This value cannot be mistaken as an item from the list. sentinel GIGO stands for garbage in, garbage out The
integrity of a program's output is only as good as the integrity of the program's input The input operation that appears just before a validation loop is known as the priming read Validation loops are also known as: error traps A condition-controlled loop always repeats a specific number of times. T or F True The while loop is a pretest loop. T or F True The following statement subtracts 1 from x: x = x - 1 T or F True It is not necessary to initialize accumulator variables. T or F False In a nested loop, the inner loop goes through all of its iterations for every single iteration of the outer loop. T or F True To calculate the total number of iterations of a nested loop, add the number of iterations of all the loops. T or F False The process of input validation works as follows: when the user of a program enters invalid data, the program should ask the user "Are you sure you meant to enter that?" If the user answers "yes," the program should accept the data. T or F False What is an infinite loop? A loop that has no way of ending and repeats until the program is interrupted. Why is it critical that accumulator variables are properly initialized? If the accumulator starts with any value other than 0, it will not contain the correct total when the loop finishes. What is the advantage of using a sentinel? When processing a long sequence of values with a loop, a better technique is to use a sentinel. Sets found in the same folderElectricity288 terms ddavidc20 MUS 150088 terms elizabeth_hayden MUS 1500 mid term99 terms jordanfarrel MUS 1500 - final - Western Michigan University51 terms BLipp22 Other sets by this creatorStarting Out With Python Chapter 377 terms Rglave Physics Ch 23: Gauss' Law11 terms Rglave Calc 2 chapter 1112 terms Rglave Chemistry115 terms Rglave Verified questionsCOMPUTER SCIENCE Under what circumstances would a client prefer a location transparent DFS? Under what circumstances would she prefer a location-independent DFS? Discuss the reasons for these preferences. Verified answer
COMPUTER SCIENCE This program should be designed and written by a team of students. Here are some suggestions: - One student should design function main, which will call the other functions in the program. The remainder of the functions will be designed by other members of the team. - The requirements of the program should be analyzed so each student is given about the same work load. - The parameters and return types of each function should be decided in advance. - The program can be implemented as a multi-file program, or all the functions can be cut and pasted into the main file. Verified answer
COMPUTER SCIENCE Which of the following reserved words is used in the class header of a class that implements an interface? a. interface, b. implements, c. abstract, d. void, e. final. Verified answer
COMPUTER SCIENCE Write a program that computes the fare on the Copenhagen Transit system given two inputs from the user: The zone number. The passenger type. Your prompts to the user must be : Enter zone number : Enter adult or child : The fare on Copenhagen Transit is specified as follows: If the zone is 2 or smaller and the ticket type is "adult," the fare is 23.0. If the zone is 2 or smaller and the ticket type is "child," the fare is 11.5. If the zone is 3 and the ticket type is "adult," the fare is 34.5. If the zone is 3 or 4 and the ticket type is "child," the fare is 23.0. If the zone is 4 and the ticket type is "adult," the fare is 46.0. If the zone is greater than 4, the fare is -1.00 (since your calculator does not handle inputs that high). Your output must be of the format: The fare for adultOrChild to zone number zoneNumber is fare. Please note that your class should be named CopenhagenTransit. Verified answer Recommended textbook solutions
Computer Organization and Design MIPS Edition: The Hardware/Software Interface5th EditionDavid A. Patterson, John L. Hennessy 220 solutions
Engineering Electromagnetics8th EditionJohn Buck, William Hayt 483 solutions
Introduction to the Theory of Computation3rd EditionMichael Sipser 389 solutions
Computer Organization and Architecture10th EditionWilliam Stallings 497 solutions Other Quizlet setsQuiz 1010 terms jonathan_dennis10 OCE1101 Chapter 590 terms melanie_t_d Quadrilaterals Review28 terms Eugenia_Latka PERMIT17 terms tanyasprague Related questionsQUESTION Many tasks, large and small, can be solved by performing a specific set of actions and making a particular set of decisions in very precise ways. These sets of actions and decisions are known as what? 15 answers QUESTION What are the 3 types of sort? 10 answers QUESTION Check all that apply to dynamic allocation of a broadcast channel with capacity C assuming there are n stations with n ≥ 2. 4 answers QUESTION the step of the IPDE where you look ahead and locate a hazard 2 answers What is the structure that causes a statement or set of statements to execute repeatedly?A repetition structure causes a statement or set of statements to execute repeatedly. Repetition structures are used to perform the same task over and over. A condition-controlled loop uses a Boolean (true/false) condition to control the number of times that it repeats.
Which C++ structureA loop is a control structure that causes a statement or group of statements to repeat. C++ has three looping control structures: the while loop, the do-while loop, and the for loop. A controlled loop contains some repetition condition which will eventually force the looping construct to terminate.
What structure allows repeated execution of a block of statements?A loop is referred to as a structure that enables repeated execution of a block of statements. A Boolean expression is evaluated within a looping structure.
Which expression executes its block of code only when a test is true?The else statement
With if statements, our programs can execute a set of instructions only if the condition is true. If we want our programs to execute a different set of instructions when the condition is false, then we can use an else statement.
|