You are on page 1of 43

Computer Programming 1

Lecture 1
Vision

A distinctively strong Christian


University integrating faith, character
and service in building up and
enhancing the quality of life.

Prepared by Prof. Edgar E. De Castro CEIT, Faculty 1-2


Mission
We, at Philippine Christian University, a church-related
academic institution, commit ourselves to;
•Provide an education that will enhance the
development of Christian character.
•Promote academic excellence and the highest quality
education.
•Be responsive to Philippine needs and conditions.
•Become responsible stewards of God’s creation and
resources.
•Foster international understanding and goodwill.
•Support the ecumenical movement.

Prepared by Prof. Edgar E. De Castro CEIT, Faculty 1-3


{ }

MOV AX, 8053h

Prepared by Prof. Edgar E. De Castro CEIT, Faculty 1-4


Introduction:
Review IC:
1.Computers,
2.Computer Network
3.the Internet,
4.World Wide Web,
CP1
1.Programming
2.The Algorithms;
3.Flowcharting

Prepared by Prof. Edgar E. De Castro CEIT, Faculty 1-5


OBJECTIVES:
• In this Chapter we will learn:

1.Machine Languages, Assembly Languages


and High-Level Languages
2.Computer Programs, Programming,
Programming Language, and Computer
Programmer
3.Program by algorithm
4.The Algorithm developing life cycle
5.Flowcharting

Prepared by Prof. Edgar E. De Castro CEIT, Faculty 1-6


Review: Complete Computer System
• Hardware
• Software
• Peopleware

Prepared by Prof. Edgar E. De Castro CEIT, Faculty 7


Intro. for CP : 1943 and 1945

Prepared by Prof. Edgar E. De Castro CEIT, Faculty 1-8


Intro. for CP :
• 1943 and 1945
• 1980s: major breakthrough with 4GL, CASE tools, object-
oriented methods

• 1990s: focus on system integration, GUI (Graphical User


Interface (applications, client/server platforms, Internet

• The new century: Web application development, wireless PDAs


(personal data assistant) , component-based applications

Prepared by Prof. Edgar E. De Castro CEIT, Faculty 1-9


Lovelace's diagram from Note G, the first published computer
algorithm

Who was the first Programmer?


Prepared by Prof. Edgar E. De Castro CEIT, Faculty 1-10
Augusta Ada King, Countess of Lovelace (10 December 1815 – 27
November 1852) was an English mathematician and writer, chiefly
known for her work on Charles Babbage's proposed mechanical
general-purpose computer, the Analytical Engine. She was the first to
recognize that the machine had applications beyond pure calculation
and published the first algorithm intended to be carried out by such a
machine. As a result, she is sometimes regarded as the first to
recognize the full potential of a "computing machine" and one of the
first computer programmers.

Prepared by Prof. Edgar E. De Castro CEIT, Faculty 1-11


Three Types of Computer Languages /
Classification of Programming Languages
1. Machine Languages,
2. Assembly Languages and
3. High-Level Languages

Prepared by Prof. Edgar E. De Castro CEIT, Faculty 1-12


1. Machine language
Def.
• Language of Computer.
• The only language computer directly
understands.
• “Natural language” of computer.
• Defined by hardware design.
•Binary digit (bit):
The digit 0 or 1
•Binary code:
• A sequence of 0s and 1s : 10101…
•Byte:
• A sequence of eight bits. 10101010 00000111

Prepared by Prof. Edgar E. De Castro CEIT, Faculty 1-13


Example:
• Early computers were programmed in machine
language.

• To calculate wages= rates * hours


• in machine language
• 100100 010001 //load
• 100110 010010 // multiply
• 100010 010011 // store

Prepared by Prof. Edgar E. De Castro CEIT, Faculty 1-14


2. Assembly language

• Assembler: Translates a program written in


assembly language in to machine language.
• English-like abbreviations representing elementary
computer operations
• Clearer to humans
• Incomprehensible ) to computers)
• Example
• load basepayadd overpaystore grosspay

Prepared by Prof. Edgar E. De Castro CEIT, Faculty 1-15


Prepared by Prof. Edgar E. De Castro CEIT, Faculty 1-16
Assembly Language

• Examples of instructions in Assembly Language and Machine


Language

• e.g. MOV AX, 8053h

Note: AL often abbreviated asm, is any low-level programming


language in which there is a very strong correspondence
between the program's statements and the architecture's
machine code instructions

Prepared by Prof. Edgar E. De Castro CEIT, Faculty 1-17


3. High-level languages
• Include BASIC, FORTRAN, COBOL, Pascal, C, C++,
C# and Java

• Similar to everyday English


• Compiler: translates a program written in a high-level
language into machine language.
• closer to human language
• Uses common mathematical notations
• The equation(Wages = rate* hours can be written
in C++ as: Wages = rate * hours;
• grossPay = basePay + overTimePay

Prepared by Prof. Edgar E. De Castro CEIT, Faculty 1-18


Another example:

1. Begin
2. A= 2
3. B= 3
4. C= A+B
5. Print C
6. If A > B then
7. Print A * B
8. End if
9. If A< B then
10. Print A-B
11. End if
12. End

Prepared by Prof. Edgar E. De Castro CEIT, Faculty 1-19


Programming : Topics
1. Programs
2. Programming Languages
3. What Is a Program Made of?
4. Input, Processing, and Output
5. The Programming Process

1-20
Prepared by Prof. Edgar E. De Castro CEIT, Faculty
What is programming / programs?

• What is a programming language?


• Why are there so many programming languages?
• What are the types of programming languages? * cont…
• Does the world need new languages?

Prepared by Prof. Edgar E. De Castro CEIT, Faculty 1-21


Definition of terms:
• Programming
• In computing, a program is a specific set of
ordered operations for a computer to
perform. In the modern computer - John von
Neumann outlined in 1945, the program
contains a one-at-a-time sequence of
instructions that the computer follows.

• Programming is a process of problem


solving.

Prepared by Prof. Edgar E. De Castro CEIT, Faculty 1-22


• A programming language is a set of rules that
provides a way of telling a computer what
operations to perform.

• A programming language is a set of rules for


communicating an algorithm.

• A set of rules, symbols and special words used


to write computer program.

Prepared by Prof. Edgar E. De Castro CEIT, Faculty 1-23


• Programming language (PL) It rovides a
linguistic framework for describing
computations.

• A PL is a notational system for describing


computation in a machine-readable and
human-readable form.

• A PL is a tool for developing executable


models for a class of problem domains.

Prepared by Prof. Edgar E. De Castro CEIT, Faculty 1-24


Programming Language Generation
1. First Generation Languages - machine level languages used
to program first-generation computers.
2. Second Generation Languages - assembly languages.
3. Third Generation Languages - high-level computer
programming languages. e.g. Fortran, ALGOL, and COBOL
popular; C, C++, C#, Java, BASIC and Pascal,
4. Fourth Generation Languages - any computer programming
language that belongs to a class of languages envisioned as an
advancement upon third-generation programming languages
(3GL). concept of 4GL was developed from the 1970s through
the 1990s, overlapping most of the development of 3GL. e.g.
Informatics MARK-IV (1967) product and Sperry's MAPPER
(1969 internal use, 1979 release).
5. Fifth Generation Languages - based on problem solving using
constraints given to the program, rather than using an algorithm
written by a programmer. are used mainly in artificial intelligence
research. e.g. OPS5 and Mercury

Prepared by Prof. Edgar E. De Castro CEIT, Faculty 1-25


What Is a Program Made Of?

Common elements in programming languages:

• Key Words
• Programmer-Defined Identifiers
• Operators
• Punctuation
• Syntax

1-26
Prepared by Prof. Edgar E. De Castro CEIT, Faculty
Programming Language, Computer Program, and
Computer Programmer
• A programmer, computer programmer, developer, coder,
or software engineer is a person who writes computer software.
• The term computer programmer can refer to a specialist in one
area of computer programming or to a generalist who writes
code for many kinds of software.

Prepared by Prof. Edgar E. De Castro CEIT, Faculty 1-27


Programs consists of the following types
of instructions:
• input: get data from the keyboard or from some
file or other device
• output: write
• math: perform some simple calculation, like
addition and multiplication
• conditional execution: check some condition
and execute one sequence of statements or
another
• repetition: repeat some sequence of operations,
usually with some variation
Prepared by Prof. Edgar E. De Castro CEIT, Faculty 1-28
Why Program?

Computer – programmable machine designed to


follow instructions.
Program/Software – instructions in computer
memory to make it do something.
Programmer – person who writes instructions
(programs) to make computer perform a task.

so, without programmers, no programs; without


programs, the computer cannot do anything.

1-29
Prepared by Prof. Edgar E. De Castro CEIT, Faculty
Programs and Programming Languages

• Program - a set of instructions directing a


computer to perform a task
• Programming Language - a language
used to write programs

1-30
Prepared by Prof. Edgar E. De Castro CEIT, Faculty
Notes:
• Closer to English but included simple mathematical
notation.
• Programs written in source code which must be
translated into machine language programs called
object code.
• The translation of source code to object code is
accomplished by a machine language system program
called a compiler.

• Alternative to compilation is interpretation which is


accomplished by a system program called an
interpreter.
• Common third generation languages; FORTRAN,
COBOL, C and C++ ◦ Visual Basic, JAVA
Prepared by Prof. Edgar E. De Castro CEIT, Faculty 1-31
• A high level language (4GL) that requires fewer instructions to
accomplish a task than a third generation language.Used with
databases ◦ Query languages ◦ Report generators ◦ Forms
designers ◦ Application generators
• Declarative languages- Functional(?): Lisp, Scheme, SML,
Also called applicative. Everything is a function, Logic: Prolog ◦
Based on mathematical logic ◦ Rule- or Constraint-based
• Imperative Programming (C),
• Object-Oriented Programming (C++)
• Logic/Declarative Programming (Prolog)
• Functional/Applicative Programming (Lisp)
• Object-oriented languages - Objects are created rather than
sequences of instructions i.e.Some third generation, and fourth
and fifth generation languages

Prepared by Prof. Edgar E. De Castro CEIT, Faculty 1-32


• Java is a general-purpose programming language that is class-
based, object-oriented (although not a pure object-oriented
language, as it contains primitive types unreliable source?), and
designed to have as few implementation dependencies as possible.

• Java was originally developed by James Gosling at Sun


Microsystems (which has since been acquired by Oracle) and
released in 1995 as a core component of Sun Microsystems' Java
platform.
• James Arthur Gosling, OC (born May 19, 1955) is a Canadian
computer scientist, best known as the founder and lead designer
behind the Java programming language

Prepared by Prof. Edgar E. De Castro CEIT, Faculty 1-33


Computer Systems: Hardware and Software
(Review)

Hardware – Physical components of a


computer
Main Hardware Component Categories
1. Central Processing Unit (CPU)
2. Main memory (RAM)
3. Secondary storage devices
4. Input Devices
5. Output Devices
1-34
Prepared by Prof. Edgar E. De Castro CEIT, Faculty
Review: Main Hardware Component Categories

1-35
Prepared by Prof. Edgar E. De Castro CEIT, Faculty
Review: Central Processing Unit (CPU)
CPU – Hardware component that
runs programs
Includes
• Control Unit
• Retrieves and decodes program
instructions
• Coordinates computer operations
• Arithmetic & Logic Unit (ALU)
• Performs mathematical operations

1-36
Prepared by Prof. Edgar E. De Castro CEIT, Faculty
Review: The CPU's Role in Running a
Program
Cycle through:
• Fetch: get the next program instruction
from main memory
• Decode: interpret the instruction and
generate a signal
• Execute: route the signal to the appropriate
component to perform an operation

1-37
Prepared by Prof. Edgar E. De Castro CEIT, Faculty
Review: Main Memory
• Holds both program instructions and data

• Volatile – erased when program terminates


or computer is turned off

• Also called Random Access Memory


(RAM)

1-38
Prepared by Prof. Edgar E. De Castro CEIT, Faculty
Review: Main Memory Organization
• Bit
• Smallest piece of memory
• Stands for binary digit
• Has values 0 (off) or 1 (on)
• Byte
• Is 8 consecutive bits 8 bits
• Has an address

• Word
• Usually 4 consecutive bytes 0 1 1 0 0 1 1 1
• NIBBLE

1 byte
1-39
Prepared by Prof. Edgar E. De Castro CEIT, Faculty
Review: Secondary Storage

• Non-volatile - data retained when


program is not running, or computer is
turned off
• Comes in a variety of media
• magnetic: floppy or hard disk drive,
internal or external
• optical: CD or DVD drive
• flash: USB flash drive
1-40
Prepared by Prof. Edgar E. De Castro CEIT, Faculty
Review: Input Devices

• Used to send information to the


computer from outside
• Many devices can provide input
• keyboard, mouse, microphone,
scanner, digital camera, disk drive,
CD/DVD drive, USB flash drive

1-41
Prepared by Prof. Edgar E. De Castro CEIT, Faculty
Review: Output Devices

• Used to send information from the


computer to the outside
• Many devices can be used for
output
• Computer screen, printer,
speakers, disk drive, CD/DVD
recorder, USB flash drive

1-42
Prepared by Prof. Edgar E. De Castro CEIT, Faculty
Friday 8:30 to 9:30
Lecture Quiz 1

Prepared by Prof. Edgar E. De Castro CEIT, Faculty 1-43

You might also like