0% found this document useful (0 votes)
67 views40 pages

Overview of Computer Programming

The document discusses the evolution of computer programming languages from machine language to high-level languages. It begins by explaining that computers operate using binary digits (0s and 1s) at the most basic level, known as machine language. Assembly language was then developed to make programming easier by using mnemonics instead of binary codes. Further advances included high-level languages that use syntax closer to natural languages, like Java. Programs in high-level languages must be compiled into machine-executable code. The document also outlines the structured process for developing programs, including planning, design, coding, debugging, and documentation.

Uploaded by

Misnomer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views40 pages

Overview of Computer Programming

The document discusses the evolution of computer programming languages from machine language to high-level languages. It begins by explaining that computers operate using binary digits (0s and 1s) at the most basic level, known as machine language. Assembly language was then developed to make programming easier by using mnemonics instead of binary codes. Further advances included high-level languages that use syntax closer to natural languages, like Java. Programs in high-level languages must be compiled into machine-executable code. The document also outlines the structured process for developing programs, including planning, design, coding, debugging, and documentation.

Uploaded by

Misnomer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

Overview of Computer

Programming
The Language of Computer

•What is the Language of Computer?

When you press A on your keyboard, the computer


displays A on the screen. But what is actually stored
inside the computer’s main memory? What is the
language of the computer? How does it store
whatever you type on the keyboard?
• Remember that a computer is an electronic device.
Electrical signals are used inside the computer to
process information. There are two types of electrical
signals: analog and digital.
• Because digital signals are processed inside a
computer, the language of a computer, called
Machine Language, is a sequence of 0s and 1s.
The digit 0 or 1 is called a binary digit, or bit.
Sometimes a sequence of 0s and 1s is referred to as a
binary code or a binary number.
• The most commonly used encoding scheme on
personal computers is the seven-bit American
Standard Code for Information Interchange (ASCII).
The Evolution of Programming
Languages
What is a Programming Language?
• The most basic language of a computer, the machine language,
provides program instructions in bits. Even though most computers
perform the same kinds of operations, the designers of the computer
may have chosen different sets of binary codes to perform the
operations. Therefore, the machine language of one machine is not
necessarily the same as the machine language of another machine.
The only consistency among computers is that in any modern
computer, all data is stored and manipulated as binary codes.
• Early computers were programmed in machine language. To see how
instructions are written in machine language, suppose you want to
use the equation:
wages = rate * hours
• to calculate weekly wages. Further, suppose that the binary code
100100 stands for load, 100110 stands for multiplication, and
100010 stands for store. In machine language, you might need the
following sequence of instructions to calculate weekly wages:
100100 010001
100110 010010
100010 010011
• To represent the weekly wages equation in machine language, the
programmer had to remember the machine language codes for
various operations. Also, to manipulate data, the programmer had
to remember the locations of the data in the main memory. This
need to remember specific codes made programming not only very
difficult, but also error-prone.
• Assembly languages were developed to make the programmer’s job easier. In
assembly language, an instruction is an easy-to-remember form called a
mnemonic. Table 1-2 shows some examples of instructions in assembly
language and their corresponding machine language code.

• Using assembly language instructions, you can write the equation to


calculate the weekly wages as follows:
Machine Language Assembly Language
100100 010001 LOAD rate
100110 010010 MULT hours
100010 010011 STOR wages
• As you can see, it is much easier to write instructions in assembly
language. However, a computer cannot execute assembly language
instructions directly. The instructions first have to be translated into
machine language. A program called an assembler translates the
assembly language instructions into machine language.
• Assembler - A program that translates a program written in assembly
language into an equivalent program in machine language.
• Moving from machine language to assembly language made
programming easier, but a programmer was still forced to think in terms
of individual machine instructions. The next step toward making
programming easier was to devise high-level languages that were closer
to natural languages, such as English, French, German, and Spanish.
Basic, FORTRAN, COBOL, Pascal, C, C++, C#, and Java are all high-level
languages.
• In Java you write the weekly wages equation as follows:

Machine Language Assembly Language High Level Language


100100 010001 LOAD rate wages = rate * hours;
100110 010010 MULT hours
100010 010011 STOR wages
• The instruction written in Java is much easier to
understand and is self-explanatory to a novice user who
is familiar with basic arithmetic. As in the case of
assembly language, however, the computer cannot
directly execute instructions written in a high-level
language. To run on a computer, these Java instructions
first need to be translated into machine language. A
program called a compiler translates instructions written
in high level languages into machine code.
• Compiler: A program that translates instructions written
in a high-level language into the equivalent machine
language.
• As a programmer, you need to be concerned only with
Step 1. That is, you must learn, understand, and
master the rules of the programming language to
create source programs
Programming Methodologies
•Two popular approaches to programming design
are the;

1. structured approach
2. object-oriented approach
structured approach
• Dividing a problem into smaller sub-problems is called structured
design. Each sub-problem is then analyzed, and a solution is obtained
to solve the sub-problem. The solutions to all of the sub-problems are
then combined to solve the overall problem. This process of
implementing a structured design is called structured programming.
The structured-design approach is also known as top-down design,
bottom-up design, stepwise refinement, and modular programming.
object-oriented approach
• Object-oriented design (OOD) is a widely used programming
methodology. In OOD, the first step in the problem-solving
process is to identify the components called objects, which
form the basis of the solution, and to determine how these
objects interact with one another.
/* This is a simple Java program.
FileName : "HelloWorld.java". */

class Hello
{
// Your program begins with a call to main().
// Prints "Hello, World" to the terminal window.
public static void main(String args[])
{
System.out.println("Hello, World");
}
}
•Lito is given 20 pesos allowance a week.
He saves 6 pesos and spends the rest for
his snacks. How much does he spend for
snacks in a week?
Program Development Process

Constructing a program is very similar to building a


house. In order to carry out a programming task in the
minimum amount of time and with the fewest possible
errors, you must follow an organized program
development process that should consist of all of the
following steps:
The Program Development Process
Program planning
Program design
Coding
Debugging

Documentation

Maintenance
The Program Development Process

1. Program planning – Decide what the program is to do.


2. Program design – plan how the program will work
3. Coding – Write the program code in an appropriate computer
language
4. Debugging – Correct any errors in the program
5. Documentation – Write a detailed description of how the program
works and how it may be used
6. Maintenance – Correct errors as users point them out. Modify the
program in response to user suggestion and needs.
1. PROGRAM PLANNING
One of the principal defects of the classic programming
language is that it allows you to sit down and start writing a
program without much thought or planning. You may be able
to get away without planning if you are writing a small
program. But as soon as the program becomes the slightest
bit complex, program planning becomes a necessity. Your
planning must include the following:
• A clear statement of what the program is
supposed to accomplish
• A list of the inputs to the program
• A list of the outputs from the program
• An analysis of the data manipulation to
be accomplished within the program
• A plan for the user interface to the
program
2. PROGRAM DESIGN
The second step in program development is
transforming your program plan a design, which can be
used as the basis for coding and debugging. In this step,
you describe the operation of your program using
either FLOWCHART or PSEUDOCODE.
A good programmer is a good planner
• Logic formulation and problem-solving are the
fundamentals of programming. It requires intricate
process of critical and analytical thinking, combined
with precision and keenness to details. The planning
stage is very important because it serves as the
backbone of any program.
3 types of program Design

1.Algorithm
2.Pseudocode
3.Flowchart
Algorithm – a logical procedure or set of steps to be followed to
arrive at a solution to a problem, An algorithm is the breaking
down of a problem in simple steps in order to find the right
answer.
Examples :
Recipe in a cookbook
Choreography of a dance

Steps in solving a problem:


1. Study the problem
2. Gather pertinent information
3. Process the information
4. Arrive at the solution
Pseudocode – an algorithm in English statements in outline form
to conceptualize it before it in a programming language .

Example:
Making a Soap
Step 1: prepare your workspace
Step 2: cut and weigh the soap base
Step 3: melt the soap base
Step 4: add the fragrance or essential oil
Step 5: add color to the melted soap
Step 6: stir the melted soap
Step 7: pour the soap in the mold
Step 8: Unmold the soap

Pseudocode cannot be executed on a real computer


Flowchart – The graphical representation of an
algorithm. Flowchart is the pictorial description of
sequenced activities and logic to be performed by the
computer for carrying out data processing. It uses
special symbols which represent a specific function

Flowcharts are used by programmers before the


actual start of any programming activities

FLOWCHART IS OTHERWISE KNOWN AS DATA FLOW


DIAGRAM
FLOWCHART IS THE SO-CALLED “BLUEPRINT “ OF A
PROGRAM
Advantages and Limitations
of Flowchart
Advantages of flowchart
1. They can be learned and applied without formal knowledge of a
programming language
2. It enforces users to give attention to significant matters over the
less significant ones
3. Provide an alternative to the usual narrative description of a system
or a program
4. Easier to understand than a program written in a particular
programming language
Limitations of Flowchart
1. Do not represent a programming language and are more of a
person-to-person means of communication
2. Cannot be viewed as a natural means of communication
3. Certain details often require a long sequence of interconnected
symbols which could easily be described in just a few lines of
explanation
4. It does not convey why a given set of operations is made
5. Do not highlight the important details since each step receives as
much attention in a flowchart as any other
Types of Flowcharts
1. Program Flowchart – describes graphically in detail the logic
operations and steps within a program and the sequence in which
these steps are to be executed for the transformation of data to
produce the needed output
2. System Flowchart – is a graphic representation of the procedures
involved in converting data on input media to data in output form
Basic Symbol of Flowchart
Input / Output Terminal symbol
symbol

Processing Predefined process


symbol symbol

On-page connector symbol


Decision
symbol
Off-page connector symbol

Preparation Flow direction indicator


symbol

Flow line
1. Input / Output symbol – represents an instruction
to an input or an output data
2. Processing symbol – is used to represent a group of
program instruction that perform a processing
function
3. Decision symbol – this diamond-shaped box
denotes a point in the program where more than
one path can be taken.
4. Preparation symbol – is used to represent an
instruction or group of instruction that will alter, or
modify a program’s course of execution
5. Terminal symbol – is used to designate the
beginning and the end of a program
6. Predefined process symbol – is a specialized process
symbol that represents a named operation or
programmed step not explicitly detailed in the
program flowchart
7. On-page connector – this is a non processing symbol
which is used to connect one part of a flowchart to
another without drawing flow lines
8. off-page connector – is used instead of the on-page
connector to designate entry to or exit from a page
when a flowchart requires more than one page
9. Flow direction indicators – are used to show the
direction of processing or data flow
10. Flow lines – are used to show reading order or
sequence in which flowchart symbols are to be read
3. CODING
The third step in development a program consists
of writing the program code. In this step, you write
computer instruction that carry out tasks described in
the program design. The computer instructions are
written in a computer language that allows you to
describe the program in a language close to English.
4. TESTING AND DEBUGGING
Testing is the process of checking that a program
actually does what you planned it to do. Debugging is
the process of correcting programming errors. Testing
and Debugging are related operations carried out at
various stages during coding and after coding is
complete.
5. Documentation
Documentation is written material used to describe a program.
Two categories of Documentation:
1. User Documentation – is a description in nontechnical terms, of
how to use the program.
2. Technical Documentation – is describe in technical term, how the
program is organized and how it operates.
6. MAINTENANCE
Maintenance involves repairing bugs that are spotted by
program user and making alterations of the program, often in response
to user request for improved operation or additional program features.
Program maintenance often must be carried out by a programmer
other than the one who did the original programming.

You might also like