Escolar Documentos
Profissional Documentos
Cultura Documentos
Programming
Programming languages
60-140-30 LECTURE 1: Algorithm and Flowchart
INTRODUCTION
Computers Hardware
3 4
Input device: To read user input data into a Processing device: To process the raw data and
computer coordinate all the other hardware devices work together
Keyboards The processor is an integrated circuit that contains the CPU
Pointing devices: Mouse, Pen input (Central Processing Unit)
Audio input devices: Microphone Two parts of the CPU
Visual and Imaging devices: Webcam, Scanner Control unit (traffic manager)
Output device: To send data to another device or To interpret software instructions and tells the other hardware
devices what to do
user Fetch, decode, execute, store
Display output: Monitor Arithmetic logic unit - ALU (calculator)
Sound output: Speaker, Headphone To perform all arithmetic and logic operations such as additions,
Hardcopy output: Printer multiplications, subtractions and division, and comparison
Mac
Programming
11
Example: Add two numbers, and if the preliminary Human-readable notation for the machine language
result is less than 10, then add 10 to the result Uses symbolic names for operations
1010 1111 Example: 1010 1111 load 15
1011 0111 1011 0111 load 7
0111 0111 ADD
0011 1010 0011 1010 CMP 10
0010 1100 0010 1100 JGE 12
0110 1010 0110 1010 ADD 10
… … 12 …
Even into the 1990s, the majority of console video
Every CPU model has its own machine code, or games were written in assembly language.
instruction set
Assembly Languages … High-level Languages
17 18
Translation of assembly language into machine Higher level of abstraction from machine language
Codes similar to everyday English
language assembler (a special computer program)
Make complex programming simpler
Disadvantages of the Low-level language:
Translation of high level language into machine language
programmer must learn the instruction set of the compilers (a special computer program)
particular processor A high level instruction (statement) is translated into many
Program must be rewritten in order to run on a machine instructions Portable
different processor type – program is not portable Example: C/C++/C#, Pascal, Fortran, JAVA, …
Algorithm Algorithm …
23 24
A procedure/method for solving a problem in terms of: Example: Write an algorithm to add two numbers
entered by user.
1. The actions to be executed
Start
2. The order in which these actions are to be executed
Read values num1 and num2.
How?
Add num1 and num2 and assign the result to sum.
Try to understand the question properly sum←num1+num2
Think of and explore your idea Display sum
Document a proper solution. Stop
Flowchart Raptor
25 26
Lecture 1: Summary
27
Some Fundamentals
Hardware and Software
Programming languages
Assigned Reading:
Chapter 1 – Introducing C
Assignment
Deadlineof the first lab assignment is on Jan. 12
Assignments should be submitted in Labs.