Back to Student Worksheet
CS Grade 6-8 Answer Key

CS: Algorithms and Flowcharts

Planning steps and showing program logic

Answer Key
Name:
Date:
Score: / 12

CS: Algorithms and Flowcharts

Planning steps and showing program logic

CS - Grade 6-8

Instructions: Read each problem carefully. Show your thinking clearly and use step-by-step logic when needed.
  1. 1

    Write an algorithm with at least 5 steps for making a peanut butter and jelly sandwich. Use clear, numbered steps.

    An algorithm is a clear set of ordered steps.

    A correct algorithm should list the steps in order, such as getting two slices of bread, spreading peanut butter on one slice, spreading jelly on the other slice, putting the slices together, and placing the sandwich on a plate.
  2. 2

    A flowchart starts with Start, then says Input age, then uses a decision diamond labeled age >= 13. If yes, it says Allow account. If no, it says Ask for parent permission. What does the decision diamond do?

    The decision diamond checks whether the age is greater than or equal to 13 and chooses the next path based on whether the condition is true or false.
  3. 3

    Put these algorithm steps in the correct order: A. Pour cereal into a bowl. B. Eat the cereal. C. Get a bowl. D. Add milk.

    Think about which step must happen before another step can work.

    The correct order is C, A, D, B. You get a bowl, pour cereal into it, add milk, and then eat the cereal.
  4. 4

    Trace this algorithm: Set score = 0. Add 5 to score. Add 3 to score. If score > 6, subtract 2 from score. What is the final value of score?

    The final value of score is 6. The score becomes 5, then 8, and because 8 is greater than 6, 2 is subtracted to make 6.
  5. 5

    In a flowchart, what shape is usually used for Start and End, and what shape is usually used for a process step such as total = total + 1?

    Different flowchart shapes show different types of actions.

    Start and End are usually shown with an oval. A process step such as total = total + 1 is usually shown with a rectangle.
  6. 6

    Write a short algorithm that decides whether a number is even or odd. Your algorithm should include an input step, a decision step, and an output step.

    A correct algorithm could say to input a number, check whether the number divides by 2 with no remainder, output that the number is even if it does, and output that the number is odd if it does not.
  7. 7

    A flowchart asks, Is the password correct? The yes path goes to Log in. The no path goes to Try again. What type of programming structure is this: sequence, selection, or repetition?

    Selection means the algorithm chooses between options.

    This is selection because the algorithm makes a choice between two different paths based on a condition.
  8. 8

    Trace this loop: Set count = 1. While count <= 4, print count and then add 1 to count. What numbers are printed?

    The numbers printed are 1, 2, 3, and 4. The loop stops when count becomes 5 because 5 is not less than or equal to 4.
  9. 9

    A student writes this algorithm for brushing teeth: 1. Put toothpaste on brush. 2. Wet toothbrush. 3. Get toothbrush. 4. Brush teeth. Explain what is wrong and how to fix it.

    An algorithm must use steps in an order that can actually be followed.

    The steps are out of order because the student needs to get the toothbrush before putting toothpaste on it or wetting it. A better order is get toothbrush, wet toothbrush, put toothpaste on brush, and brush teeth.
  10. 10

    Write the flowchart steps in words for this process: Start -> Input temperature -> If temperature >= 100 then Output Boiling, else Output Not boiling -> End.

    The flowchart starts by taking a temperature as input. It checks whether the temperature is at least 100. If it is, it outputs Boiling, and if it is not, it outputs Not boiling, then the flowchart ends.
  11. 11

    An algorithm has these steps: Set total = 0. For each number in 2, 4, 6, add the number to total. Output total. What does the algorithm output?

    Keep a running total after each number is added.

    The algorithm outputs 12. It adds 2, 4, and 6 to the total, so 0 + 2 + 4 + 6 equals 12.
  12. 12

    Create a simple algorithm for a game character that has 3 lives. Each time the character hits an obstacle, it loses 1 life. The algorithm should repeat until lives = 0, then output Game over.

    A correct algorithm could say to set lives to 3, repeat while lives is greater than 0, check for an obstacle, subtract 1 life if an obstacle is hit, and when lives equals 0 output Game over.
LivePhysics™.com CS - Grade 6-8 - Answer Key