< previous page page_38 next page >

Page 38
Exam Preparation Exercises
1. Explain why the following series of steps is not an algorithm, then rewrite the series so it is.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Shampooing
  (1) Rinse.
  (2) Lather.
  (3) Repeat.
2. Describe the input and output files used by a compiler.
3. In the following recipe for chocolate pound cake, identify the steps that are branches (selection) and loops, and the steps that are references to subalgorithms outside the algorithm.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Preheat the oven to 350 degrees
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Line the bottom of a 9-inch tube pan with wax paper
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Sift 2¾ c flour, ¾ t cream of tartar, ½ t baking soda, 1 ½t salt, and 1¾ c sugar into
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
a large bowl
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Add 1 c shortening to the bowl
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
If using butter, margarine, or lard, then
add 2/3 c milk to the bowl,
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
else
(for other shortenings) add 1 c minus 2 T of milk to the bowl
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Add 1t vanilla to the mixture in the bowl
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
If mixing with a spoon, then
see the instructions in the introduction to the chapter on cakes, else
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
(for electric mixers) beat the contents of the bowl for 2 minutes at medium speed, scraping the bowl and beaters as needed
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Add 3 eggs plus 1 extra egg yolk to the bowl
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Melt 3 squares of unsweetened chocolate and add to the mixture in the bowl
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Beat the mixture for 1 minute at medium speed
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Pour the batter into the tube pan
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Put the pan into the oven and bake for 1 hour and 10 minutes
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Perform the test for doneness described in the introduction to the chapter on cakes
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Repeat the test once each minute until the cake is done
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Remove the pan from the oven and allow the cake to cool for 2 hours
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Follow the instructions for removing the cake from the pan, given in theintroduction to the chapter on cakes
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Sprinkle powdered sugar over the cracks on top of the cake just before serving

 
< previous page page_38 next page >