Module_12

Module 12: Computer Programming Concepts

What you will learn about:

  • Functions of compilers and interpreters

  • Identify various computer languages and what they are used for

  • Explain concepts of algorithms, and flow of a structured, linear, and iterative instruction chart

Because computers can only register two conditions (on and off or 1 and 0), there must be a way to change these signals into commands that can be useful to both humans and the machine code.

A compiler creates the program by checking the source code (created by a human usually) for language statements to see if they are correct. These statements may have syntax errors (misspelled commands or incorrect commands) and logic errors (errors that don't do what was intended). If everything is correct, the compiler converts the source code into machine code.

Programmers use a programming language like C++, Visual Basic, COBOL, Fortran, HTML, Lisp, Python, Java, etc. to send instructions to the computer. The compiler for an individual language converts these instructions into a language the machine can understand.

An interpreter creates a program, but it only executes line by line. It does not link files or generates machine code. This way programmers can check their code line by line instead of looking through a whole lot of source code. Interpreters are used mostly by beginning programmers.

Assignment: Create a document in Module 12 that has the following:

  • A chart that identifies the following languages and describes what each is used for and who might use this language.

Here is an example: Fortran has been used for factory automation and designing infrastructure. If you are an engineer, you might use Fortran. In the chart you have created, explain the uses of the following:

  • C++

  • Visual Basic

  • COBOL

  • HTML

  • Lisp

  • Python

  • Javascript

  • Java

  • SQL

  • Pascal

  • PHP

Resources:

Programmers use ALGORITHMS, a set of rules for calculations and to solve problems using step-by-step procedures.

A structured language allows the programmer to divide the whole program into smaller units called subroutines. These subroutines might handle a particular responsibility and can be easily used again in many different programs and shared among programmers. C and Python are structured programming languages along with C++, Java, Visual Basic, and PHP. Structured languages may be linear in design but others may use iterative instructions such as:

  • If this happens, then this happens (If/Then statement)

  • Do this until this happens (loop statement)

These types of structures can be charted to assist the programmer in creating the appropriate instructions. These are called LOGIC DIAGRAMS.

Simple IF/THEN statement chart

If this condition is true, then take Action 2.

Here is an example:

If X<100, then Print, "Good Job".

If X > 100, then Print, "Try Again".


Assignment: On your slides, copy this graphic and write an If/then/else statement of your own.

Of course, programming structures can become very complicated. Here is an example of an If-Then-Elseif statement. Charting the logic first can be like a road map for the programmer.

RESOURCES:

ASSIGNMENT for Module_12 Slide Deck:

Draw the logic diagram for the following program :

Input Lastname,

If Lastname starts with an "A", "B", or "C", then print, "Please go to entrance door 1."

Else print, "Please go to entrance door 2."