What is a Program?
------------------

.. index::
   single: program
   
A **program** is a sequence of instructions that specifies how to perform a
computation. The computation might be something mathematical, like
solving a system of equations or finding the roots of a polynomial, but
it can also be a symbolic computation, like searching and replacing text
in a document or (strangely enough) compiling a program.

The instructions (or commands, or statements) look different in
different programming languages, but there are a few basic functions
that appear in just about every language:

input:
    Get data from the keyboard, or a file, or some other device.

output:
    Display data on the screen or send data to a file or other device.

math:
    Perform basic mathematical operations like addition and
    multiplication.

testing:
    Check for certain conditions and execute the appropriate sequence of
    statements.

repetition:
    Perform some action repeatedly, usually with some variation.

Believe it or not, that’s pretty much all there is to it. Every program
you’ve ever used, no matter how complicated, is made up of functions
that look more or less like these. Thus, one way to describe programming
is the process of breaking a large, complex task up into smaller and
smaller subtasks until eventually the subtasks are simple enough to be
performed with one of these simple functions.


.. fillintheblank:: program_1

   A(n) |blank| is a series of instructions that are used to perform a 
   computation.
    
   - :[Pp][Rr][Oo][Gg][Rr][Aa][Mm]: Correct!
     :.*: Try again!


.. dragndrop:: program_2
   :feedback: Try again!
   :match_1: input|||the program user enters a few ordered pairs when prompted in the terminal
   :match_2: output|||the calculated distances are saved to a file
   :match_3: math|||the program calculates the distance between two ordered pairs
   :match_4: testing|||the program makes sure that the calculated distance is non-negative
   :match_5: repetition|||the program continues executing as long as there are more data points to compute distance

   Match each term to an example of it.