§ — — Computer Programming 1
A computer is an electronic device that accepts data from the user, processes it, produces results, and stores those results for future use. Data is raw, unorganized facts; information is data that has been processed into something meaningful.
Hardware refers to the physical, mechanical parts of a computer — the devices you can touch. This includes the CPU, keyboard, mouse, hard drive, and other components.
Software is the set of instructions that drives the computer to perform tasks. Software falls into two categories:
A program is the ordered set of instructions a computer follows to process data into information. Writing that set of instructions is called programming.
The five-step programming process:
Types of errors:
Before writing code, plan the logic. Two common tools: flowcharts and pseudocode.
A flowchart is a visual representation of a solution using standardized shapes connected by arrows.
| Symbol | Name | Purpose |
|---|---|---|
| Oval | Terminal | Marks start or stop |
| Parallelogram | Input/Output | User input or output of results |
| Rectangle | Process | Computation or data manipulation |
| Diamond | Decision | Condition — TRUE or FALSE paths |
| Arrow | Flow Line | Direction of execution |
| Circle | Connector | Connects parts across pages |
Three fundamental control structures:
1. Sequential — steps execute one after another in order.
START → Initialize → INPUT → PROCESS → OUTPUT → STOP
2. Selection — a decision point where one of two paths is taken.
START → INPUT A
IF A < 0 → OUTPUT "NEGATIVE"
ELSE IF A == 0 → OUTPUT "INVALID"
ELSE → OUTPUT "POSITIVE"
STOP
3. Repetition — steps are repeated until a condition is met.
START → N=0
LOOP while N < 10:
N = N + 1
IF N is odd: OUTPUT N
STOP
These three structures — sequence, selection, repetition — are sufficient to construct any program logic.
An algorithm is a step-by-step description of a solution written in structured English-like language. Also called pseudocode.
Common pseudocode conventions:
+, -, *, /→ (arrow pointing to the variable)INPUT or READOUTPUT, PRINT, or DISPLAYSequential example — sum of two numbers:
ALGORITHM sum
A → 0, B → 0, SUM → 0
INPUT A, B
SUM → A + B
OUTPUT SUM
END sum
Sequential example — product of three numbers:
ALGORITHM product
A → 0, B → 0, C → 0, PRODUCT → 0
INPUT A, B, C
PRODUCT → A * B * C
OUTPUT PRODUCT
END product
Selection example — positive or negative number:
ALGORITHM pos_neg
N → 0
INPUT N
IF N < 0 THEN
OUTPUT "NEGATIVE"
END IF
IF N == 0 THEN
OUTPUT "INVALID"
ELSE
OUTPUT "POSITIVE"
END IF
END pos_neg
Review questions (write answers in your own words):
Algorithm exercises — write a flowchart AND pseudocode for each:
The volume of a rectangular box is V = length × width × height. Design an algorithm that takes the three dimensions and displays the volume.
Design an algorithm that converts hours to minutes. Output: "3 hours is equal to 180 minutes."
Given three numbers a, b, and c, design an algorithm that computes their sum, difference, product, quotient, and sum of their squares.
A store sells four candy types: Type A ₱35/kg, Type B ₱45/kg, Type C ₱56/kg, Type D ₱57.50/kg. Design an algorithm to calculate total cost from the weight of each type purchased.
On Mars, a 100-pound Earth person weighs 38 pounds. On Jupiter, 264 pounds. Design an algorithm that takes Earth weight and displays Mars and Jupiter weight.
Free Sample
That was 1 of 29 reviewers with answer keys in Computer Programming 1. Unlock all of them for the semester.
Unlock all reviewers →ProReviewer — locked
Drills, code labs, and full solutions.
ProReviewer — locked
Drills, code labs, and full solutions.
Done with this module? Track it — your progress shows on the subject list.
Up next
Lesson 2: Introduction to C→