Algorithm Building Blocks

It has been proven that any algorithm can be constructed from just three basic building blocks. These three building blocks are Sequence, Selection, and Iteration.

Building Block
Common name
Sequence Action
Selection Decision
Iteration Repetition or Loop


    An Action is one or more instructions that the computer performs in sequential order (from first to last).
    Example:  Compute 17 plus 31.

    A Decision is making a choice among several actions.
    Example: If you listen to KMEL radio, print "Friend of the Camel", otherwise print "Don't like Camels."

    A Loop is one or more instructions that the computer performs repeatedly.
    Example: Print "GOOD GRIEF, CHARLIE BROWN" 77 times.

INSTRUCTIONS

The following pages contain a number of simple problem statements.  Read each problem statement and determine whether it is an Action, Loop, or Decision.  On a separate piece of paper write the problem number and "A" for Action, "L" for Loop, or "D" for Decision.

1.    Print the name of your best friend.
2.    Print "RAIDERS ARE CHAMPS" 39 times.
3.    If you were born in California, print "NATIVE", otherwise print "RESIDENT".
4.    Compute 7 times 17.
5.    Print the name of the team that won the superbowl.
6.    Print the sentence "STAMP OUT SILICON FEAR" ninetynine times.
7.    If your name is the same as the teacher's first name, print "SAME", otherwise print "DIFFERENT".
8.    Print "Michael Jackson eats Wheaties".
9.    If your best score on Frogger is better than your friend's, print "I'm better" otherwise print "My friend is better".
10.    Print the name of a movie star you like the best.
11.    If Ronnie Lott is heavier than Joe Montana, print "Ronnie's heavier", otherwise print "Joe's heavier."
12.    Print the name "Kilgore Trout" in each row of the display screen.
13.    Print the pattern 'XXOOXX' seven times.
14.    Print your name in the center of the screen.
15.    Compute the square root of 17.
16.    Round off your temperature to the nearest degree.
17.    Print an asterick ("*") in each column of the top row of the display screen.
18.    Ask the user for his or her age.
19.    Sally has 50 dollars in the bank.  She plans to deposit 5 dollars each month.  For each month of the year, calculate her new account balance.
20.    Print a square in the upper right corner of the screen.
21.    Garfield the cat is eight years old, and weighs seven pounds.Print the sum of his age and weight.
22.    If there are more letters in your name than there are in Johnny Carson's name, print "Mine's longer", otherwise print "Mine's shorter".
23.    If Jackie is taller than Nancy then print Jackie's name, otherwise print Nancy's name.
24.    Ask the user for his or her name.
25.    Print 27 dollar signs ($) on a line.
26.    Compute the sum of 7 times 3 and 9 times 5.
27.    Ask the user for today's date.
28.    For each student in the class input his or her weight and add it to a total.
29.    compute the sum of odd numbers between 11 and 51.
30.    For each number from 1 to 50, print the number and its square root.  (Print a table of square roots for numbers up to 50.)
31.    Joe can read 65 pages a day.  Compute how long it would take him to finish a 350 page book.
32.    30 days before the start of the Olympics scalped tickets were being sold at $100.  As the big day nears the price goes up $50 each day. Print a list showing the price of a ticket on each day of the month preceding the start of the Olympics.
33.  Print 75 question marks (?) on a line.
34.  In a regular 1 hour TV program there are 4 commercial breaks.  Compute the total number of commercials if there are 7 commercials each break.
35.    Barbara earns 17 dollars every day.  Assume she works 24 days/month, and compute her monthly salary.
36.    For each line of the display screen, print "XO" all the way across the line.
37.    Print "XXXXOOOO" ten times.
38.    Print a conversion table from Fahrenheit degrees to Celsius degrees for 0 to 250 degrees.
39.    Jill wants to find the total playing time of her favorite album, "Synchronicity."  For each song on the album, enter the playing time and add it to a total.
40.    Simon the rugmaker is taking inventory.  For each rug in the shop, input the price of the rug and add it to a total.
41.    The city of Cornstalk, Nebraska has a population of 200.  19 people move to the city each year.  Print a table of the city's population for each year until the population reaches 400.
42.    The island of Tonga has a tortoise population of 300, which increases by 3% each year.  Print a table of the number of turtles on the island for each year until the population reaches 500.