Understanding Computer Programming

Osher Lifelong Learning Institute
University of Illinois, Urbana-Champaign

Scott Badman, Instructor


Topic: All Programming Elements

February 18, 2016


Sequential execution:
    The computer simply does each instruction in the order they are written in the program.

Input and Output:
    Done by the Operating System (Windows, Mac OS X, Android, etc.) on request by a program (we'll see how later).

Variables:
    Human friendly names for locations in the computer's memory where a program can store a number.

    Examples: number divisor intermediate remainder

Arithmetic expressions:
    Variables and numbers combined using ordinary arithmetic operators (+, -, * for multiplication, / for division)
        using parentheses, the same way you did in school.

    Example: intermediate - divisor

Logic expressions:
    Logical expressions can make "True" and "False" decisions by comparing two numbers as "equal",
        "greater than", or "less than", possibly combined with AND, OR, or NOT.

    Example: intermediate >= divisor (read as "intermediate is greater than or equal to divisor)

Assignment:
    The way a program puts a new value into a variable, replacing the old value.
    Only a variable can be to the left of the assignment symbol (the backarrow, <--, in our pseudocode;
        the equals sign, =, in most computer languages).
    Any number, variable, or arithmetic expression can be to the right of the assignment symbol.
    The value on the right is calculated, and placed into the variable on the left.

    Example: intermediate <-- number

Repetition - WHILE loops:

    A WHILE loop first tests the numeric comparison(s) at the beginning, such as: intermediate >= divisor
    Multiple numeric expressions can be combined with AND, OR, or NOT.
    The result of the numeric comparisons is always either TRUE or FALSE.

    WHILE comparison(s)
        One or more lines of code that is done if the comparison is true.
    END WHILE    The computer automatically jumps back to the beginning of the while loop to test the comparison(s) again.
    In any case, the program continues here after the WHILE loop comparison(s) test false.

Selection - IF-ELSE-ENDIF statements:

    An IF-ELSE-ENDIF statement first tests the numeric comparison(s), such as: intermediate <= divisor
    Multiple numeric expressions can be combined with AND, OR, or NOT
    The result of the numeric comparisons is always either True or False

    IF comparison(s)
        One or more lines of code that is done if the comparison is true.
    ELSE
        One or more lines of code that is done if the comparison is false.
    END IF
    In any case, the program continues here after the IF-ELSE-ENDIF completes.


Modularity:
    Any but the simplest program must be divided into independent chunks of code for the convenience of the human programmers.
    Modularity isolates code so it can be debugged more easily.
    Modularity isolates code so it can be upgraded more easily.
    Modularity isolates variables and reduces the chance that they can inadvertently be given wrong values.
    Modularily facilitates multiple programmers working on the same project, because they can concentrate on smaller parts of the code.
    Examples: Subroutines, Functions, Procedures, Objects


Data Structures:
    Data structures are how data is organized in memory.
    Data structures are necessary for storage of large amounts of data.
    Good data structures can have a large positive effect on the speed of a program.
    Examples: Arrays, Trees, plus many other types and variations



Understanding Computer Programming

Osher Lifelong Learning Institute
University of Illinois, Urbana-Champaign

Scott Badman, Instructor