02 - Intro to Computers and Programming
02 - Intro to Computers and Programming
Programming
The synchronous sessions are recorded (audiovisual recordings). The students are not required to keep their
cameras on during class.
The audiovisual recordings, presentations, readings and any other works offered as the course materials aim
to support remote and online learning. They are only for the personal use of the students. Further use of
course materials other than the personal and educational purposes as defined in this disclaimer, such as
making copies, reproductions, replications, submission and sharing on different platforms including the digital
ones or commercial usages are strictly prohibited and illegal.
The persons violating the above-mentioned prohibitions can be subject to the administrative, civil, and
criminal sanctions under the Law on Higher Education Nr. 2547, the By-Law on Disciplinary Matters of Higher
Education Students, the Law on Intellectual Property Nr. 5846, the Criminal Law Nr. 5237, the Law on
Obligations Nr. 6098, and any other relevant legislation.
The academic expressions, views, and discussions in the course materials including the audio-visual
recordings fall within the scope of the freedom of science and art.
§ This is where the computer stores a program and the data it is using, while
that program is running
§ Commonly known as Random Access Memory (RAM)
§ CPU can quickly access the RAM
§ It is volatile, used for temporary storage while program is running. Contents
are erased when computer is off.
§ e.g., you lose electricity
§ That’s why we save to “disk” = secondary storage!
§ RAM is faster to access than secondary storage,
but it often has smaller size
§ Holds large amounts of data and programs for long periods of time
§ Programs/data stored here are loaded to main memory when needed
§ Types of secondary storage:
§ Hard Disk Drive: Magnetically encodes data onto a spinning circular disk
§ Solid State Drive: Faster than disk drive, no moving parts, stores data in solid
state memory
§ Optical devices: data encoded optically
§ Flash memory: portable physical disk (e.g., USB disks, USB sticks)
§ Input: data the computer collects from users and other devices
§ Input device: device that collects the input data
§ Examples: keyboard, mouse, touchscreen, scanner, camera, etc.
§ Note: In different contexts and based on a different standard 1 kilobyte (KB) can
refer to 103 bytes, 1 megabyte (MB) to 106 bytes and so on…
1 0 0 1 1 1 0 1 = 128 + 0 + 0 + 16 + 8 + 4 + 0 + 1 = 157
20 (1)
21 (2)
22 (4)
23 (8)
24 (16)
25 (32)
26 (64)
27 (128)
Place values
§ Programming languages
§ are formal, human-made languages that have been designed to express
computations
§ have strict syntax rules that govern the structure of statements
§ are literal – mean exactly what is written, no metaphors
§ Structure is important
§ learn to parse the program and identify the code structure
55 31 D2 89 E5 8B 45 08
56 8B 75 0C 53 8D 58 FF
Compiler 0F B6 0C 16 88 4C 13 01
83 C2 01 84 C9 75 F1 5B
5E 5D C3
Pseudocode:
Step 1. Input (get) a and b
Step 2. Check if a > b
If so, go to Step 3
Otherwise, go to Step 4
Step 3. Print “a is greatest”
Step 4. Print “b is greatest”
Pseudocode:
Good exercise for you! J
Pseudocode:
Step 1. Input (get) N
Step 2. Initialize i = 1
Step 3. Check if i <= N
If so, go to Step 4
If not, stop
Step 4. Print i
Step 5. Increment i by 1
Step 6. Go to Step 3
Implement
Design the Correct syntax Test the Correct logic
the program
program errors program errors
(write the code)
The most important Write the necessary Check errors Consider different While testing your
part of the program codes using the produced by the use cases and be program, correct logic
development cycle selected programming compiler/interpreter sure that your errors that cause your
language program works program give
Independent from a These errors are for all these cases unexpected/incorrect
programming easy to find results
language
Editor Console
(open, edit, run files) (Interactive Use)
§ String literals must be enclosed in quote marks to mark where the string data
begins and ends
§ You can either use single-quote marks (') or a set of double-quote marks (")