Computer
Programming
Lecture 1
Introduction To Computer
Programming
Mr. Abbas kh. Ibrahim
Welcome to
(Computer Programming for
Petroleum Engineering 2019)
Course Info
TA: Mr. Tahir (Computer Lab.)
Introduction to Computer Programming with MATLAB
Class Hours
– sunday : 9:00 am - 3:00 pm
Office: Petroleum Engineering Dept.
Objectives
Introduces the student to the world of programming
through MATLAB to develop scientific and engineering
models.
The student will be able to read, understand and write
beginner level programs using MATLAB.
The student will be able to solve mathematical and
Petroleum Engineering problems using MATLAB.
COURSE OUTLINE
Introduction.
MATLAB Syntax and Commands.
Use of MATLAB to Solve Engineering Problems.
Algorithms.
Conditional Statement.
Repetition Loops.
Subprograms.
Matrix Manipulation.
File I/O.
GRADING
We’ll discuss that later !
History of Computing
1800S
George Boole – devised Boolean algeb
ra
Charles Babbage – created "analytical
engine“
Augusta Ada Byron – first computer pr
ogrammer
Herman Hollerith – founder of compa
ny that would become IBM
1930S
Alan Turing – deciphered German cod
e in WWII; father of artificial intelligen
ce
John V. Atanasoff – inventor of first el
ectronic digital special purpose compu
ter
1940S
Howard Aiken – built large scale digit
al computer, Mark I
Grace M. Hopper – originated term "d
ebugging"; pioneered development a
nd use of COBOL
John Mauchley and J. Presper Eckert –
built first large scale general purpose
computer, ENIAC
1940S CONTINUED
John von Neumann – developed store
d program concept
Maurice V. Wilkes – built EDSAC, first
computer to use stored program con
cept
John Bardeen, Walter Brattain, and
William Shockley – developed transist
or that replaced vacuum tubes
1950S
John Backus – created Fortran; early u
ser of interpreters and compilers
Reynold B. Johnson – invented the dis
k drive
Donald L. Shell – developed efficient s
orting algorithm
1960S
JohnG. Kemeny and Thomas E.
Kurtz – invented BASIC
Corrado Bohm and Guiseppe Ja
copini – proved that any progra
m can be written with only 3 str
uctures: sequence, decision, an
d loops
EdsgerW. Dijkstra – stimulated
move to structured programmin
g by declaring "GOTO" harmful
1960S CONTINUED
Harlan B. Mills – advocated use
of structured programming
Donald E. Knuth – wrote definiti
ve work on algorithms.
Ted Hoff, Stan Mazer, Robert N
oyce, and Frederico Faggin – de
veloped first microprocessor
1960S CONTINUED
Douglas Engelbart – invented computer mouse
1970S
Ted Codd - software architect; l
aid the groundwork for relation
al databases
Paul
Allen and Bill Gates - cofou
nders of Microsoft Corporation
Stephen Wozniak and Stephen J
obs - cofounders of Apple Com
puter Inc.
Dan Bricklin and Dan Fylstra - wr
ote VisiCalc, the first electronic s
preadsheet program
1970S CONTINUED
Dennis
Ritchie - creator of the C
programming language.
KenThompson - created the Uni
x operating system
Alan Kay – developer of Smalltal
k, a pure object-oriented langua
ge
Don Chamberlain - created a dat
abase programming language, la
ter known as SQL,
1980S
Phillip
“Don” Estridge - at IBM
directly responsible for the su
ccess of the personal comput
er.
MitchellD. Kapor - cofounde
r of Lotus Corporation
TomButton - group product
manager for applications pro
grammability at Microsoft;
headed the team that develop
ed QuickBasic, QBasic, and Vis
ual Basic.
1980S CONTINUED
AlanCooper - considered the fat
her of Visual Basic.
Tim Berners–Lee - father of the W
orld Wide Web.
Charles Simonyi - father of Word.
Bjarne
Stroustrup - creator of the
C++ programming language.
RichardM. Stallman - founded Fr
ee Software Foundation
1990S
Marc Andreessen - inventor of the Web
browser.
James Gosling – creator of Java.
Linus Torvalds - developed the popular L
inux operating system.
2000S
Sergey M. Brin and Lawrence E. Pa
ge – founders of Google
Mark Zuckerberg – founder of Face
book.
Steve Chen, Chad Hurley, and Jawe
d Karim – founders of YouTube.
An Introduction to Computers
and Problem Solving
Representation of the problem solving p
rocess
Problem-solving: approach like algebra class
• How fast is a car traveling if it goes 50 miles in 2
hours?
• Input : two inputs : 50 miles , 2 hours.
• Process: speed = distance/time = 50/2.
• Output: 25 mph (miles per hour).
Program Planning Tips
• Always have a plan before trying to write a progra
m
• The more complicated the problem, the more
complex the plan must be.
• Planning and testing before coding saves time cod
ing.
Program development cycle
1. Analyze: Define the problem.
2. Design: Plan the solution to the problem.
3. Choose the interface: Select the objects (text boxes, buttons,
etc.).
4. Code: Translate the algorithm into a programming language.
5. Test and debug: Locate and remove any errors in the progra
m.
6. Complete the documentation: Organize all the materials that
describe the program.
What is a Computer?
Computer
– Device capable of performing computations
and making logical decisions
– Computers process data under the control of
sets of instructions called computer program
s
Hardware
– Various devices comprising a computer
– Keyboard, screen, mouse, disks, memory, C
D-ROM, and processing units
Software
– Programs that run on a computer
Computer Organization
Six logical units in every computer:
– Input unit
• Obtains information from input devices (keyboard,
mouse)
– Output unit
• Outputs information (to screen, to printer, to control
other devices)
– Memory unit
• Rapid access, low capacity, stores input information
– Arithmetic and logic unit (ALU)
• Performs arithmetic calculations and logic decisions
– Central processing unit (CPU)
• Supervises and coordinates the various components o
f the computer
– Secondary storage unit
• Cheap, long-term, high-capacity storage
• Stores inactive programs
Computer Architecture
Common Softwares
Operating System
Compilers
Assemblers
Interpreters
Evolution of Programming languages
– First Generation : Machine languages
• Strings of numbers giving machine specific instructions
• Example:
+1300042774
+1400593419
+1200274027
– Second Generation : Assembly languages
• English-like abbreviations representing elementary computer operations (tr
anslated via assemblers)
– Example:
LOAD BASEPAY
ADD OVERPAY
STORE GROSSPAY
– Third Generation : High-level languages
• Codes similar to everyday English
• Use mathematical notations (translated via compilers)
• Example: grossPay = basePay + overTimePay
Programming Language hierarch
y
What does the computer understa
nd?
• Computer only understands machine language i
nstructions.
Assembler
• Instructions written in assembly language m
ust be translated to machine language instru
ctions :
– Assembler does this
• One to one translation : One AL instruction
is mapped to one ML instruction.
• AL instructions are CPU specific.
Compilation into Assembly
Source Assembly
Program Compiler Language
Assembly Assembler Machine
Language Language
Compiler
• Instructions written in high-level language also m
ust be translated to machine language instructions
:
– Compiler does this
• Generally one to many translation : One HL instru
ction is mapped to many ML instruction.
• HL instructions are not CPU specific but compiler
is.
Compilation
Source Target
Program Compiler Program
Input Target Program Output
Interpreter
• An interpreter translates high-level instructions into an inte
rmediate form, which it then executes. In contrast, a
compiler translates high-level instructions directly into
machine language.
• Compiled programs generally run faster than interpreted p
rograms.
• The advantage of an interpreter, however, is that it does no
t need to go through the compilation stage during which m
achine instructions are generated. This process can be time
-consuming if the program is long. The interpreter, on the
other hand, can immediately execute high-level programs.
For this reason, interpreters are sometimes used during the
development of a program, when a programmer wants to a
dd small sections at a time and test them quickly.
Interpretation
Source
Program
Interpreter Output
Input