Upload
archibald-warren
View
218
Download
2
Embed Size (px)
Citation preview
New ways of learning week
Sign up at: www.library.dmu.ac.uk/Home/Calendar
Monday 25th November
Tuesday 26th
November
Wednesday 27th
November
Thursday 28th
November
Friday 29th November
Finding images using
databases (11-12)
Putting data into words in
your dissertation
(11-12)
Visual approaches for
effective learning (11-12)
How to make Groupwork
work(12-1)
Using social media to raise
your online profile (12-1)
Mind over matter: use
your imagination for study success
(12-1)
Electronic newspapers. Today and Yesterday.
(12-1)
Be more productive and manage your
stress (12-1)
Writing in science and technology
(1-2)
Thinking about your
dissertation: writing the proposal
(1-2)
New ways of seeing:
assignment planning,
research and discovery (1-2:30)
Taking a critical
approach to your work (5:30-6:30)
Writing in art and design (2:30-3:30)
Introduction to Repetition
ProblemWhat do we do when we want to do something over
and over again?E.g. Add the numbers 1 – 10 to a list box…
lstTest.Items.Add(1)lstTest.Items.Add(2)lstTest.Items.Add(3)lstTest.Items.Add(4)lstTest.Items.Add(5)lstTest.Items.Add(6)lstTest.Items.Add(7)lstTest.Items.Add(8)lstTest.Items.Add(9)lstTest.Items.Add(10)
SolutionUse a loop (repetition)
Start of loop (set rules for number of repeats)Stuff we want to repeat
End of Loop
Types of LoopsType 1 For-Next Loop This loop repeats a section of code a specified number of
times. So if we wanted to do a task 1000 times, this kind of loop is ideal.
Type 2 While Loop (Pre processing) This loop repeats a section of code until a certain condition
is met, that is the condition may be met on the first attempt or on the thousandth, we simply don’t know!
Type 3 Do Loop (Post processing) Always runs the code once then continues until a certain
condition is met.
To make loops work…For any loop to work we need to know three
things…When the loop will startWhen the loop will endWhere the loop is up to at a given point
Do While Loop Structure
while (Condition){
//code to repeat goes here}
Things to Watch with Do While Loops!What is wrong with the following loops?
Indexes Counters and AccumulatorsIndexes
Indexes Counters and AccumulatorsCountersAnswers the question “How Many?”
How manyloan payments?
AccumulatorsAnswer the question “How much?”
Indexes Counters and Accumulators