Fundamentals of Programming - Comprehensive Course Study Guide
- Course Title: Fundamentals of Programming
- Manual Version: Manual Ver 1.0
- Academic Field: Information Technology
- Authors and Faculty:
- Elsie Isip
- Lalaine Abad
- Emily Yabut
- Donnalyn Lopez
- Jesfer Dela Cruz
- Leonila Valdez
- Roger Primo Jr.
- Course Core Focus: Utilization of data structures and algorithms to efficiently solve computing and real-life problems.
- Data Structures Covered: Dynamic arrays, lists, stacks, queues, trees, graphs, and maps.
- Complexity Analysis: Evaluation of the time complexity and space complexity of algorithmic solutions.
- Course Table of Contents:
- Topic 1: Overview of Computer Programming
- Topic 2: Elements of High-Quality Programs
- Topic 3: Understanding Structure
- Topic 4: Making Decision
- Topic 5: Looping
- Topic 6: Arrays
Learning Outcomes
- Describe all primary components of computer systems.
- Develop foundational program logic.
- List and explain the sequential steps in the program development cycle.
- Write pseudocode statements according to standard guidelines and draw standard flowchart symbols.
- Implement sentinel values to conclude program execution loops.
- Describe various programming and user execution environments.
- Trace the historical evolution of programming models and paradigms.
Fundamental Computer System Concepts
- Computer System Definition: A combination of all components required to process and store data using a computer, comprising both hardware and software.
- Hardware:
- Definition: The physical equipment and devices associated with a computer.
- Examples: Keyboards, mice, speakers, printers.
- Physical Form Factors: Hardware is manufactured differently based on system size, ranging from massive mainframes and laptops to micro-embedded devices inside consumer goods like telephones, automobiles, and thermostats. Core operations across all sizes remain functionally similar.
- Control Requirements: Hardware cannot function independently; it requires explicit computer instructions detailing how and when data items are input, processed, output, or stored.
- Software:
- Definition: Computer instructions that dictate hardware operations; instruction sets created by programmers.
- Acquisition Methods: Prewritten software stored on physical media (disks) or downloaded via the Internet, or custom programs written directly by programmers.
- Examples: Business word processing and accounting programs, consumer music players, and video games.
- Programming: The exact process of writing software instruction sets.
Software Classification and System Operations
- Classification of Software:
- Application Software: All programs applied to end-user tasks, such as word processing, spreadsheets, payroll management, inventory tracking, mobile apps, and video games.
- System Software: Programs designed to manage and control computer hardware and internal operating functions. Includes operating systems like Microsoft Windows, Linux, or UNIX for mainframes/servers, and Google Android or Apple iOS for mobile smartphones.
- Three Major Computer Operations:
- Input:
- Raw data items enter the computer system and are loaded into internal memory.
- Data Definition: Raw material, unorganized text, numbers, facts, and figures regarding entities (e.g., products, customers, personnel), images, audio files, and user interactions (mouse clicks, finger-swiping gestures).
- Input Devices: Keyboards, mice, touchscreens.
- Processing:
- Organizing, sorting, verifying accuracy, or running mathematical calculations on input data items.
- Processing Hardware: Central Processing Unit (CPU). Modern mobile devices (smartphones, tablets) contain multiple processor cores, requiring specialized multithreading programming techniques.
- Output:
- Displaying or delivering processed results to human users.
- Information Definition: Data items that have been processed, structured, and presented in a meaningful format for human interpretation and evaluation.
- Output Devices: Monitors, printers.
- Storage Retention: Output can be stored on nonvolatile media (hard drives, flash media, cloud storage across the Internet) for subsequent retrieval or to serve as input for subsequent programs.
Programming Languages, Memory, and Code Translation
- Programming Languages & Syntax:
- Programming Languages: Formal instruction sets used by programmers (e.g., Visual Basic, C#, C++, Java).
- Program Code / Coding: The specific instruction set written in a programming language and the act of writing it.
- Syntax: Strict grammatical rules governing word usage and punctuation in a given programming language.
- Syntax Errors: Direct violations of language usage rules, flagged by translators.
- Memory and Storage Mechanisms:
- Computer Memory (RAM / Random Access Memory): Internal, volatile, temporary storage. Stores running programs and active data items for high-speed CPU access. All contents are lost upon power disruption.
- Permanent Storage: Nonvolatile storage media (hard drives, solid-state drives, flash drives) where contents persist across power outages. Systems can be configured to automatically backup RAM content to nonvolatile storage at regular intervals.
- Source Code vs. Object Code:
- Source Code: High-level, human-readable programming language statements.
- Object Code / Machine Language / Binary Language: Low-level statements formatted as series of 0s and 1s representing the physical on/off state of micro-level circuits.
- Translators (Compilers and Interpreters):
- Translates high-level source code into low-level machine code.
- Identifies and displays syntax errors along with error messages to allow developer correction.
- Executables: Created once source code is translated without syntax errors. Executable machine-language programs can be run repeatedly without needing retranslation unless the source code is modified.
- Execution / Running: The CPU carrying out translated machine instructions.
The Program Development Cycle
- Step 1: Understand the Problem:
- Programmers write software to fulfill requirements for users or end users.
- Requires examining documentation: original user service requests, sample output reports, and descriptions of available input data fields.
- Step 2: Plan the Logic:
- Programmers map out the required logical steps and order of execution.
- Algorithm: The sequence of steps or rules designed to solve a problem.
- Desk-Checking: The manual process of walking through logical steps on paper before writing code.
- Planning Tools: Flowcharts and pseudocode.
- Step 3: Code the Program:
- Writing source code using a chosen high-level programming language.
- Languages share fundamental baseline features: input, arithmetic handling, conditional evaluation, and output capability.
- Step 4: Use Software to Translate the Program into Machine Language:
- Executing a compiler or interpreter to convert code into machine language.
- Code must be compiled iteratively until zero syntax errors remain to build an executable file.
- Step 5: Test the Program:
- Executing syntax-free code using carefully structured test data.
- Logical Error: Occurs when syntactically valid code executes incorrect operational logic for the context (e.g., subtracting taxes instead of adding them).
- Step 6: Put the Program into Production:
- Deploying software for organizational execution.
- Conversion: The complete operational transition process, which may include training data-entry staff, training users on report reading, and reformatting existing corporate databases (can require months or years).
- Step 7: Maintain the Program:
- Modifying active production software due to regulatory changes (e.g., new tax laws), input file schema modifications, or updated output requests.
- Maintenance requires repeating the development cycle. Massive overhaul requests may result in retiring old software and initiating a new development cycle from scratch.
Pseudocode and Flowchart Standards
- Pseudocode Definition: An English-like logical representation of problem-solving steps ("false code").
- Pseudocode Structural Standards:
- Main programs begin with
start and end with stop; these keywords must align vertically. - Module invocations are appended with empty parentheses
(). - Modules begin with the module name and end with
return; these words must align vertically. - Each individual statement performs exactly one action (input, processing, or output).
- Program statements inside
start or module headers must be indented uniform spaces. - Statements must fit on a single line where possible; continuation lines are indented further.
- Statements begin with lowercase letters.
- Trailing punctuation (like periods) is omitted.
- Flowchart Symbols & Guidelines:
- Parallelogram (Input/Output Symbol): Represents input ingestion or output display operations.
- Rectangle (Processing Symbol): Represents internal operations, calculations, and assignments.
- Flowlines (Arrows): Connect geometric shapes to depict operational sequence, reading top-to-bottom and left-to-right.
- Terminal Symbol (Racetrack/Oval): Marks the start/begin and stop/end points of logical routines.
- Decision Symbol (Diamond): Represents evaluation of conditional expressions returning mutually exclusive answers (e.g., yes/no, true/false).
Repetition Structures and Sentinel Values
- Looping: The repeated execution of a sequence of instructions.
- Sentinel Value (Dummy Value):
- A predetermined input value used explicitly to signal program termination.
- The input value must be a non-usable data point (e.g., entering
0, 999, or -1 when calculating positive values). - Evaluated inside a diamond decision symbol to branch execution away from the loop body to the termination symbol.
- End-of-File (
eof): An automated system signal or internal code embedded at the end of data files used as a sentinel when artificial dummy values are impractical.
Programming and User Environments
- Programming Environments:
- Plain Text Editors: Lightweight programs without advanced formatting features (e.g., Microsoft Windows Notepad). Programs saved via text editors require minimal storage space (e.g., a standard C# doubling script occupies roughly 314bytes).
- Integrated Development Environments (IDEs): Comprehensive software suites providing code editors, compilers, auto-completion, visual syntax highlighting (color-coded keywords and data types), and step-by-step interactive debugging tools (e.g., Microsoft Visual Studio for Visual Basic, C++, and C#). IDE projects consume significantly more disk space.
- User Environments:
- Command Line Interface (CLI): Text-based terminal where users enter commands and input directly via text prompts.
- Graphical User Interface (GUI): Visual user interface utilizing graphical controls like text boxes, buttons, and drop-down menus operated via mouse pointer or touch interactions.
Evolution of Programming Paradigms
- Historical Evolution:
- 1940s Programming: Early systems required manually typing raw memory addresses and complex machine codes.
- Modern Programming: Modern high-level languages utilize natural language elements, symbolic variable names, and modular structure breakdown.
- Procedural Programming:
- Focuses on step-by-step procedures and computational routines created by programmers.
- Deconstructs large tasks into structured subtasks focused directly on data manipulation actions (e.g., receiving payroll data, calculating gross pay, writing output records).
- Object-Oriented Programming (OOP):
- Focuses on conceptual entities called objects, defining their attributes (data properties) and behaviors (actions).
- Example Application Breakdown:
Employee Object: Attributes include Name and Social Security Number; Behaviors include receiving a raise and adding dependents.Paycheck Object: Attributes include Employee Name and Check Amount; Behaviors include calculating totals and printing output.
Assessment Tasks and Algorithmic Logic
- Task 1: Value Scaler
- Logic: Accept user input x, calculate Output=x×10, and display result.
- Task 2: Cube Geometry Metrics
- Logic: Accept edge length s.
- Calculations:
- Surface area of single side: Aside=s2
- Total surface area of cube: Atotal=6×s2
- Volume of cube: V=s3
- Output: Display Aside, Atotal, and V
- Task 3: Work Duration Multiplier
- Logic: Accept daily hours worked h
- Calculations:
- Hours in 5-day week: Hweek=5×h
- Hours in 252-day work year: Hyear=252×h
- Output: Display Hweek and Hyear
- Task 4: Binary Arithmetic Operations
- Logic: Accept two numbers a and b
- Calculations:
- Sum: Sum=a+b
- Difference: Difference=a−b
- Output: Display Sum and Difference
- Task 5: User Age Calculation
- Logic: Accept current year Ycurrent and birth year Ybirth
- Calculation: Age=Ycurrent−Ybirth
- Output: Display Age
- Task 6: Payroll Calculations
- Part A (Gross Pay): Accept hourly pay rate r and hours worked h. Calculate Gross Pay=r×h. Display Gross Pay.
- Part B (Net Pay): Accept withholding tax rate t (as a decimal percentage). Calculate Net Pay=Gross Pay×(1−t). Display Net Pay.
- Task 7: Currency Conversion
- Logic: Accept amount in US Dollars D
- Calculations: Convert D to Euros (E) and Japanese Yen (Y) using active exchange rates.
- Output: Display converted values E and Y
- Task 8: Elapsed Time Decomposition
- Logic: Accept total elapsed time in seconds S
- Calculations:
- Minutes: M=⌊S/60⌋
- Remaining Seconds: R=S(mod60)
- Example: Given S=130seconds, program calculates M=2minutes and R=10seconds.
- Output: Display M and R
Recommended References
- Burd, B. (2021). Beginning Programming with Java for Dummies (6th ed.).
- Crutcher, P. (2021). Essential computer science: a programmer's guide to foundational concepts.
- Ellison, B. (2022). Java for Beginners: A Crash Course to Learn Java Programming in 1 Week (Programming Languages for Beginners).
- Horstmann, C. (2019). Core Java: volume II-advanced features.
- Sebesta, R. (2020). Concepts of Programming Languages (11th ed.).
- Farrell (2024). Programming Logic and Design (10th ed.). Cengage.