# Introduction to Algorithms/Flow Control

This is a lesson in in the course, Introduction to Algorithms, which is a part of The School of Computer Science

## Flow Control

Our current toast making algorithm works well if you are making toast for yourself, but what if you have a few friends around for breakfast and you need to make them toast as well? The algorithm clearly needs to be improved so that we can make toast for everyone. Also, simply waiting for the toasted is very boring, we could be doing something else while we wait. The third problem with making toast for friends is that they are fussy, what if some of them want butter whilest others prefer margarine, or even just plain toast

Algorithm for making buttered toast (4.0)

``` LET A = a loaf of bread
LET T = a toaster
LET P = a plate
LET B = some butter
LET M = some margarine

FOR every friend (F) eating toast{
LET S = cut slice from A
move S to T
turn on T
WHILE T is not finished{
talk to F
}
move S to P

IF F likes B{
LET X = B
}ELSEIF F likes M{
LET X = M
}ELSE{
LET X = NOTHING
}