Problem Solving, Programming Languages

 

Main Topics


 
Problem Solving  Program Development
Programming Languages
How Computers Store Information



 Problem Solving
People make decisions every day to solve problems that affect their lives. The problem may be unimportant, such as what to eat or what to watch on television, or as important as choosing a new career. If a bad decision is made, time and resources are wasted, so it's important that people know how to make decisions well.

There are six steps to follow to help assure the best decision is made:

  1. Identify the Problem
  2. Understand the problem
  3. Identify alternative ways to solve the problem
  4. Select the best way to solve the problem from the list of alternative solutions
  5. List instructions that enable you to solve the problem using the selected solutions.
  6. Evaluate the solution
An every day example of problem solving might be: What to do this evening?
  1. Identify the problem: How do individuals want to spend the evening?
  2. Understanding the problem: consider the knowledge base of the participants. The only solutions are ones that everyone involved would know how to do.
  3. Identify Alternatives
    • Watch television
    • Invite friends over
    • Play chess
    • Go to the movies
    • Go shopping
  4. Select the best way to solve the problem
    • Eliminate alternatives that are not acceptable, such as those that cost too much money
    • Specify the pros and cons of the remaining alternatives
    • Weigh the pros and cons to make a final decision
  5. Prepare a list of steps (instructions) that will result in a fun evening
  6. Evaluate the solution-Are we having fun yet?
Return to the beginning


Program Development

The first step in writing instructions to carry out a task is to determine what the output should be, that is, exactly what the task should produce. The second step is to identify the data, or input necessary to obtain the output. The last step is to determine how to process the input to obtain the desired output. We determne what we want, get the needed input and process the input to produce the desired output.

This IPO cycle is visually represented like this:

Input -->Process-->Output

Program Planning

A recipe is a good example of a plan. The ingredients and the amounts are determined by what is to be baked. That is, the output determines the input and processing. The recipe or plan, reduces the number of mistakes you might make if you tried to bake with no plan at all. While it is difficult to imagine an architect building a bridge or a factory without a detailed plan, many programmers (particularly beginning students!) will try to write programs without first making a careful plan. the more compicated the program, the more complex the plan must be.
  • Analyze: Define the problem
    • Be sure you understand what the program should do, that is, what the output should be. Have a clear idea of what data, or input are given and the relationship between the input and the desired output.
     
  • Design: Plan the solution to the problem
    • Find a logical sequence of precise steps that solve the problem. Such a sequence of steps is called an algorithm.
     
  • Choose the Interface:
    • Select the objects (text boxes, command buttons, graphics etc.)
    • Determine how the input will be obtained and how the output will be displayed
     
  • Code: Translate the algorithm into a programming language

  • Test and Debug
    • Locate and remove any errors in the program
    • Testing is the process of finding errors in the program and debugging is the process of correcting the errors found.
     
  • Complete the documentation: Organize all materials that describe the program
 
 
Return to the Beginning


Programming Languages

Programming is the art of creating sequences of instructions that tell a computer to carry out a task. A sequence of instructions is known as a program. It is possible to write a program directly in machine language, binary numbers that encode data and the instructions to be performed by a computer's processor. Writing a program in machine language is extremely difficult. Therefore, people have created special programming languages for use in writing programs.

A programming language is a set of written symbols that instruct computer hardware to perform specific operations. All computer languages are controlled by a set of rules called syntax, which is the equivalent of the grammar rules in English.

There are several hundred programming languages used today. Although the specifics for each language may vary, certain basic instructions are included in all programming languages.

Input/Output instructions transfer instructions and data between the central processing unit and input and output devices.

Arithmetic instructions perform mathematical operations such as addition, subtracion, division and multiplication.

Logic instructions determine comparisons, such as equal to, not equal to, less than, greater than.

Control instructions alter the order in which the instructions are to be executed.

Before a computer can execute or run a program written in a higher level language, the program must be translated into machine language that can be read by the computer. Special programs known as compilers are used to do such translations.

 
LOW-LEVEL PROGRAMMING LANGUAGES
1st Generation Languages Consist of the machine language for different types of processors. Machine language is a binary code made up of 1s and 0s. It is the only programming language that the computer can understand. Machine language programs have the advantage of fast execution speed and efficient use of memory. However, they require a detailed knowledge of how computers work.
2nd Generation Languages Known as assembly languages, use abbreviations to represent machine language instructions. For example, instead of using 1s and 0s to represent the addition operator, a programmer might us the abbreviation AD. Before the computer can use an assembly language it must translate the assembly language into machine languagel. The program the converts assembly language into machine langugage is called an assembler. Programming in assembly languages still proved to be quite difficult, so higher level languages were developed.
HIGH-LEVEL PROGRAMMING LANGUAGES
3rd Generation Languages A high-level language is one with instructions that closely resemble human language and mathematical notation. They are much easier to learn and use than machine or assembly language. A high-level language must be translated into a machine language before the computer can use it. Two different language-translator programs are used to translate high-level languages: (1) compilers and (2) interpreters. 

A compiler translates a whole program called the source code all at one time, before the program is executed. Once converted, the program is stored in machine readable form called the object code. The object code can be immediately executed at any time. The source code can be updated and recompiled into new object code to make changes 

An interpreter translates a program into machine language one line at a time, executing each line of the program after it has been translated. The translation is not saved, so the program must be interpreted every time it is run. 

Today, most applications are written in third-generation languages such as FORTRAN, LISP, COBOL, BASIC, Pascal, C, C++ and Java. Lingo is also a third-generation language.

4th Generation Languages These accomplish more with fewer statements and often employ visual tools to make the programmer's job easier. An example of a 4th generation programming language is Visual Basic.
5th Generation Languages These are now under development and will make use of artificial intelligence and will use commands that are even more like natural language.
Object Oriented Languages A traditional programming language treats the data and procedures in a program as separate entities. A programmer is responsible for appling active procedures (progamming instructions) to passive data structures (such as files). An Object Oriented programming language treats a program as a series of objects and messages. An object is a combination of data and procedures that are stored together as a reusable unit. Messages are procedures that are sent between objects. 

Examples of Object Oriented Programming Languages include: Lingo, SmallTalk, Objective C, C++, and HyperTalk.

Return to the Beginning




How Computers Store Information
 
The engineers who developed modern computers needed a simple system for representing information, one that could be given an equally simple corresponding physical form. In a computer all information is represented by binary numbers which are constructed solely of the symbols 0 and 1. The beauty of binary numbers was that they could be represented by simple switches that were either off (0) or on (1). The earliest of these "switches" were vacuum tubes.

Unlike the familiar decimal numbers, which are in base 10, binary numbers are in base 2. When using the decimal number system, a person counts from zero up to nine and then, to represent the number ten, carries a 1 to the tens place and writes a 0 in the ones place:

1, 2, 3, 4, 5, 6, 7, 8, 9, 10
When using the binary number system, a person counts from zero to one and then to represent the number two, carries a 1 to the twos place and writes a 0 in the ones place:
0, 1, 10, 11 (0, 1, 2, 3 in decimal)
 
Binary Number Decimal Number
0 0
1 1
10 2
11 3
100 4
101 5
110 6
111 7
1000 8
1001 9
 
In computer jargon, a single piece of data, which can be either a 1 or a 0, is referred to as a binary digit, or bit. To represent other items in computers, such as alphabetic letters, punctuation marks, special symbols and codes for directions, one can assign each item an arbitrary binary number that becomes its code. An eight-digit binary number, referred to as a byte, can be used to represent one of 256 (2 to the 8th power), separate symbols and characters.

To a computer, all is 1s and 0s. Binary numbers are the machine language that a computer understands. A human, however, has a hard time writing a program or reading output in machine language. Therefore programmers have looked for ways to simplify binary coding. One method is to use hexidecimal or base sixteen, numbers. The decimal system makes use of ten characters, 0-9. The hexidecimal systems adds another six characters, the capitals letters A-F to represent the numbers 10-15. You have most likely encountered hexidecimal numbers as RGB color codes.

Programmers have also made their jobs easier by creating programming languages that are less cumbersome to read, write and understand than machine language.

Return to the beginning

 
 
written by Andrea Polli
edited by Schuy Jewell

Columbia College Chicago

Programming for Interactive Mulitmedia I Home