CS 135 - Computer Science I - 6. Repetition: While and For Loops. 6. 6.a Repetition Structures. Reminder: three types of control structures. ⢠Structure theorem.
René Doursat Department of Computer Science & Engineering University of Nevada, Reno Fall 2005
Computer Science I CS 135 0. Course Presentation 1. Introduction to Programming 2. Functions I: Passing by Value 3. File Input/Output 4. Predefined Functions 5. If and Switch Controls 6. While and For Loops 7. Functions II: Passing by Reference 8. 1-D and 2-D Arrays 10/10-12/2005
CS 135 - Computer Science I - 6. Repetition: While and For Loops
2
Computer Science I CS 135 6. Repetition: While and For Loops a. Repetition Structures b. While Loops c. Do/While Loops d. For Loops
10/10-12/2005
CS 135 - Computer Science I - 6. Repetition: While and For Loops
3
Computer Science I CS 135 6. Repetition: While and For Loops a. Repetition Structures 9 Reminder: three types of control structures 9 Why is repetition needed? 9 While, do/while and for loops
b. While Loops c. Do/While Loops d. For Loops
10/10-12/2005
CS 135 - Computer Science I - 6. Repetition: While and For Loops
4
6.a Repetition Structures Reminder: three types of control structures
¾ Sequence, selection and repetition structures
10/10-12/2005
CS 135 - Computer Science I - 6. Repetition: While and For Loops
5
6.a Repetition Structures Reminder: three types of control structures
¾ Structure theorem 9 it is possible to write any computer program by using only three basic control structures that are easily represented in pseudocode: sequence structures selection structures introduce branching (“jumps”) in the sequential logic repetition structures
¾ Sequence structures 9 straightforward execution of one processing step after another 9 sequence of pseudocode statements: do this, do that, then this, then that, etc. 10/10-12/2005
CS 135 - Computer Science I - 6. Repetition: While and For Loops
6
6.a Repetition Structures Reminder: three types of control structures
¾ Selection structures 9 condition and choice between two actions, depending on whether the condition is true or false 9 represented by the pseudocode keywords IF, THEN, ELSE, and ENDIF
¾ Repetition structures 9 block of statements to be executed repeatedly, as long as a condition is true 9 represented by the pseudocode keywords WHILE and ENDWHILE (or DOWHILE and ENDDO)
10/10-12/2005
CS 135 - Computer Science I - 6. Repetition: While and For Loops
7
6.a Repetition Structures Why is repetition needed?
¾ A computer can repeat a group of actions → repetition structures 9 examples: calculate 100 student grades pour water in the saucepan until it is full cook the pasta until it is “al dente” 9 pseudocode example: WHILE water_level < pan_height Add 1 tablespoon to water_volume water_level = water_volume / pan_surface ENDWHILE 10/10-12/2005
CS 135 - Computer Science I - 6. Repetition: While and For Loops
8
6.a Repetition Structures Why is repetition needed?
¾ Repetition allows to efficiently use variables 9 for example, repetition allows to input, add, and average multiple numbers using a limited number of variables 9 adding four numbers without a loop (the old-fashioned way): declare a variable for each number, input all the numbers and add all the variables together 9 adding four numbers with a loop (the high-tech way): → create a loop that iteratively reads a number and adds it to a variable holding the sum of the numbers
10/10-12/2005
CS 135 - Computer Science I - 6. Repetition: While and For Loops
9
6.a Repetition Structures Why is repetition needed? void main() { // declare variables int num1, num2, num3, num4, sum; // prompt user cout > num2; cout > num4;
void main() { // declare variables int num, sum = 0;
for 4 numbers number: ";
// prompt and increment sum 4 times cout > num; sum += num;
Mar 6, 2006 - 13. 6.a Repetition Structures. Why is repetition needed? ⢠Benefits of ... times or 10,000 times the same task without changing the code.
Jun 3, 2006 - it is possible to write any computer program by using only three basic control .... statement follows expression and can be any C++ statement.
blindness and to characterize its temporal properties. Subjects' ability to re- ...... pound noun phrase (e.g., âSailors in bars discuss sand bars which are danger-.
processing of visually presented lists. I. House l-----v. $?+O. (Rl)Grass +d$e. Truck *. 'A similar distinction has been proposed by Kahneman & Treisman (1984) ...
The overall transfer function (CLG or Closed. Loop Gain) of the ..... This is the essence of fractional-N synthesis. It .... We have looked at phase noise in a free-.Missing:
which structures have been recently determined in solution by. NMR and .... BCE methodology as explained in Materials and Methods and below. ... mechanics.
which structures have been recently determined in solution by. NMR and ..... A direct view of the first ten conformations of .... generates no physical distortions of the initial molecular structure except for ..... Gesteland,R.F., Cech,T.R. and Atki
As people examine their world, the proximal stimulus changes position on their retinae with every saccade, but they perceive the world as being stable.
... the same resonance frequency in nuclear magnetic resonance spectroscopy ... Each spin 1/2 can be described by a set of four basis operators ... which can be experimentally chosen, while the fea- ... Problem 2 : Off-resonance decoupling a.
developed along this line to solve Computer Vision prob- lems, using a small ... ples inspired from Darwin's principles of biological evo- lution. 2. Evolutionary ...
To realize ATLAS' distinguishing, dynamic features, we ex- tend the Fractal component ... The fact that MSS SoS evolve dynamically during op- eration time also ...
array over time that results from making a saccade is dif- ferent from that which ...... an A and K parameter for each shift size, shown as Model B in Table 1.
traditionally as space constancy, and which we will call visual stability ..... the basis of pilot data, indicating a wide range of detection fre- quencies, and in ...
QBF for Quantified Boolean Formulae (QBF) has been ac- knowledged for the ..... for every nontautologous clause δ (viewed as the set of its literals) and every ...
eB(tâÏ)Ψ(0) ËF(µ(c), ΦY â(Ï) + hµ(c)(Y â(Ï)))dÏ. With the decomposition C = N ..... Appl., 1109 (1985), 472â491. Received May 2002; revised December 2002.
tem, for which runtime evolution is a key requirement, as components join and ... Introduction ... ATLAS is used in a current MSS implementation, discussing ... meaning that offered services may vary in terms of func- ..... Innovations in Systems.
SAT, used as target languages for knowledge compilation. For each fragment C ... PS is the smallest set of words defined inductively as follows:1. 1. true, false ...
Interaction between inter-repetition dependences and high-level transformations in ..... where oi and Pi are the origin and the paving of the tiler Ti. This valid ...
pet medications tramadol tramadol co codamol together again lyrics is vicodin or tramadol more addictive than heroin pictures extraire tramadol ixprim dosage of ...
Feb 6, 2007 - The aim of the present study was to answer this question. .... 50% of all cases in each sample to fall above (or below) the com- mon median.
usually plugged in a host computer using the PCI-Express bus, that can provide important ... The main drawback of these accelerators lies in their programming model. ...... SIGPLAN symposium on Principles and Practice of Parallel Programming. pp. ...
We are grateful to François Irigoin, Ronan Keryell, and Fabien Coelho for their valuable advices. References. 1. Alias, C., Darte, A., Plesco, A.: Program Analysis ...