L0 - Eng Problems - Intro To PL
L0 - Eng Problems - Intro To PL
Programming
King Abdulaziz University
Faculty of Engineering
Electrical Engineering Dept.
EE 201
9/3/2024 C-intro OE 1
Structured Programming
& Matlab
9/3/2024 C-intro OE 2
Structured programming (SP)
what is SP ?
9/3/2024 C-intro OE 3
Computers Generations - -Past
to Present & Beyond
9/3/2024 C-intro OE 4
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 programs
Hardware (HW)
◼ Various devices comprising a computer
Keyboard, screen, mouse, disks, HW
memory, CD-ROM, and central Computer
processing units, registers etc.
SW
Software (SW)
◼ Programs that run on a computer
9/3/2024 C-intro OE 5
Computer Hardware Architecture
101011 101011
1
0
1
1
1
0 0
0
1
1
1
0
1
1 1
1 1 0
0 0 1 1
0 0 1 1 0
1 1
1 1 1
1
0 0 1
0
0
1 1 1 1
1 1 0
1
1
1
010101000100001
011101110010101
Machine Language
9/3/2024 C-intro OE 6
Computer Hardware Organization
A central processing unit (CPU) consists of
◼ an arithmetic/logic unit (ALU) where math and logic
operations (program instructions)are performed,
◼ a control unit which directs most operations (program
instructions)by providing timing and control signals,
◼ and registers that provide short-term data storage
and management facilities.
a memory unit that stores instructions and data, and
input (e.g. keyboard, mouse, microphone, disk drive,
etc.) and output (e.g. monitor, status indicator lights,
speakers, disk drive, etc.) units that are used to transmit
data into and out of the computer.
9/3/2024 C-intro OE 7
Perforated (punched) cards as one of
the 1st input devices for machine language
(o’s and1’s)
9/3/2024 C-intro OE 8
???
So, Computer used the machine
language (1001101….) between its
components, the question ??
How can the user deal with
components ?
Operating system
9/3/2024 C-intro OE 9
What Is an Operating system?
An interface between the hardware
and the user.
9/3/2024 C-intro OE 10
As obvious before that:
Computer only understands machine
language instructions.
We need a way to convert the
instructions of the HLL – written with
natural language – to ML.
???
9/3/2024 C-intro OE 11
Translation from HLL to ML
√
√
9/3/2024 C-intro OE 13
Assembler
Instructions written in assembly
language must be translated to
machine language instructions :
◼ Assembler do it
One to one translation : One AL
instruction is mapped to one ML
instruction.
AL instructions are CPU specific.
9/3/2024 C-intro OE 14
Translation from HLL to ML
√
√
√
9/3/2024 C-intro OE 15
Programming Language (PL)
Definition :
9/3/2024 C-intro OE 16
Execution model
9/3/2024 C-intro OE 17
Compiler
Instructions written in high-level
language also must be translated to
machine language instructions :
◼ Compiler do it
Generally, one to many translation :
One HL instruction is mapped to many
ML instruction.
HL instructions are not CPU specific but
compiler is.
9/3/2024 C-intro OE 18
Interpreter
An interpreter translates high-level instructions into an
intermediate form, then executes.
In contrast, a compiler translates high-level instructions
directly into machine language.
Compiled programs generally run faster than
interpreted programs.
The real need of interpreter comes where compiler fails
to satisfy the software development needs.
If the source code is huge in size, then the compilation
duration increased.
Interpreters are designed to translate single instruction
at a time and execute them immediately.
9/3/2024 C-intro OE 19
Programming approaches
Imperative programming. (The oldest, works on the logic of “First do this then do that”)
◼ (SQL, Xquery)
Structured programming approach.(improvement of imperative,
◼ (C, C++, Pascal, Ada, Matlab etc.) extensive use of flow control)
9/3/2024 C-intro OE 20
Main Programming approach
9/3/2024 C-intro OE 21
Translation from HLL to ML
√
√
√
√
9/3/2024 C-intro OE 22
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 (translated 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
9/3/2024 C-intro OE 23
Basic 66
C 73
C ++ 80
Matlab 84
Python 91
Java 95
C# 2001
9/3/2024 C-intro OE 24
Structured Programming
Structured programming
◼ Disciplined approach for writing
programs
◼ Clear, easy to test, debug, and modify
Structured programming takes time
to master
9/3/2024 C-intro OE 25
Structured Programming
(continued…
FUNCTION 4 FUNCTION 5
9/3/2024 C-intro OE 27
Structured Programming
(continued…
9/3/2024 C-intro OE 29
Structured Programming
(continued…
Data Data
Function Function
Object 3
Data
Function
9/3/2024 C-intro OE 32
Structured Programming VS
Object-Oriented
The main difference is that :
structured programming In contrast, object
deals with the flow of oriented programming
execution, and not, primarily deals with data
primarily, with the data. issues. In a pure object
It has to do with the oriented approach, the
organization of the flow of program
code, rather than the execution is treated as
data. It also eliminates bits of behavior
arbitrary jumps associated with the
(GOTOs) in code blocks packets of data that are
and functions. "objects".
9/3/2024 C-intro OE 33
MATLAB
An
overview
9/3/2024 C-intro OE 34
MATLAB Overview
Why MATLAB in this course
What is MATLAB?
History of MATLAB
◼ Who developed MATLAB
◼ Why MATLAB was developed
◼ Who currently maintains MATLAB
Strengths of MATLAB
Weaknesses of MATLAB
9/3/2024 C-intro OE 35
Why MATLAB in this course ?
The purpose of the EE201 course is to
provide students with the necessary
skills to solve engineering problems
using computer programming. In this
course, students will learn how to
apply programming fundamentals and
utilize its flexibility and ease of use in
both academic and professional
purposes.
9/3/2024 C-intro OE 36
Why MATLAB in this course ?
9/3/2024 C-intro OE 37
Why MATLAB in this course ?
Structured programming is a
technique used to design programs,
and various platforms can be used to
teach this concept, such as C, Python,
and Java.
However…!
9/3/2024 C-intro OE 38
Why MATLAB in this course ?
MATLAB has been selected for this course
due to its additional advantages for
engineering students, including familiarity
with the package that will enable them to
utilize MATLAB's essential engineering
applications in the future, such as signal
processing, fuzzy logic, neural networks,
control systems, modeling and simulation,
image processing, and more.
9/3/2024 C-intro OE 39
What is MATLAB?
MATLAB
◼ MATrix LABoratory
◼ Interactive system
◼ Programming language
9/3/2024 C-intro OE 40
History of MATLAB
Developing Software to MATLAB
◼ Fortran subroutines for solving linear
(LINPACK) and eigenvalue (EISPACK)
problems
◼ Developed primarily by Cleve Moler in
the 1970’s
9/3/2024 C-intro OE 41
History of MATLAB (continued…
9/3/2024 C-intro OE 43
History of MATLAB (continued…
9/3/2024 C-intro OE 44
Strengths of MATLAB
(continued…
9/3/2024 C-intro OE 45
Strengths of MATLAB
(continued…
9/3/2024 C-intro OE 46
Weaknesses of MATLAB
MATLAB is NOT a general purpose
programming language.
MATLAB is an interpreted language
(making it for the most part slower
than a compiled language such as
C++).
MATLAB is designed for scientific
computation and is not suitable for
some things (such as parsing text).
9/3/2024 C-intro OE 47
Individually answer the following : Activity(1)
1. Type of PL ?
ML AL HLL
2. Which type of HLL ?
S. P. O.O.P Both
3. Uses ?
Assembler Interpreter Compiler