Computer Basics Study Notes

Chapter 1: Computer Basics

Overview of Computer Basics

  • Course Code: ET1016 / ET1025
  • Assessment Components: Includes the following evaluation metrics:   - Unsupervised Quizzes (Ongoing) + GP (CA2) - Weight: 15%   - Lab Test (LAB1) - Weight: 15%   - Supervised Online Mid-Module Quiz (CA5) - Weight: 20%   - Project (LAB3) - Weight: 25%   - Supervised Online End-Module Quiz (CA9) - Weight: 25%   - Total Weight: 100%

Introduction to Computer Systems

  • A computer system consists of two main components: Hardware and Software.
Hardware
  • Definition: Refers to the actual physical devices of the computer system.
  • Functionality: Hardware requires instructions to perform tasks.
Software
  • Definition: A set of instructions telling the computer what to do, known as a Computer Program.
  • Programming Languages: Various languages exist for writing computer programs.

Basic Computer Architecture

  • A computer system comprises four main parts:   1. CPU (Central Processing Unit)   2. Memory   3. I/O Interfacing Circuitry   4. 3-Bus System    - Components of Bus System:      - Data Bus      - Address Bus      - Control Bus
  • Roles of CPU:   - Controls system operations   - Performs arithmetic and logical operations using the ALU (Arithmetic Logic Unit)   - Governed by the Clock and Control Unit

Memory Composition

  • Memory is essential for storing programs and data.
  • Types of Memory:   - Primary Memory:     - RAM (Random Access Memory): Temporarily stores data and is volatile.     - ROM (Read-Only Memory): Non-volatile memory containing essential instructions.   - Secondary Memory:     - Devices include Hard disks, DVD-ROMs, USB Thumb drives, etc.     - Non-volatile storage for long-term data retention.
  • Memory Addressing Example (640K memory structure):   - Address     - 0x00000 to 0x9FFFF   - Bits Architecture: One Byte consists of 8 bits.

I/O Interfacing Circuitry

  • Components of I/O circuitry include:   - Speaker Circuit   - Printer Circuit   - Keyboard Circuit   - Monitor Circuit   - Audio Circuit   - USB Circuit   - Data Bus and Address Bus connectivity

Computer Languages

  • Categories of Computer Languages:   1. Machine Language   2. Assembly Language   3. High-Level Language
Machine Language
  • Definition: The only language understandable by computer hardware, consisting of binary data (0s and 1s).
  • Machine Code: The binary code representing instructions for the computer.
Assembly Language
  • Definition: A higher-level language than machine language, utilizing mnemonic codes.   - Examples:     - ADD for addition     - SUB for subtraction     - CMP for compare
  • Translation: Requires an assembler to convert assembly language instructions into machine code.
  • Ease of understanding compared to machine language but still prone to errors.
High-Level Language
  • Features:   - Uses statements similar to English.   - Employs everyday mathematical notations.   - A single statement corresponds to multiple machine code instructions.
  • High-level programs require translation to machine code for execution.
Translation Methods
  • Types:   1. Compiler: Translates the entire program into machine code before execution.   2. Interpreter: Translates and executes one high-level language statement at a time.
  • C++ Language: The primary high-level language for this module. Developed from C, a major language for engineering applications.

C Language Development

  • Developers: Dennis Ritchie and Ken Thompson at AT&T Bell Laboratories for UNIX OS development.
  • Historical Context: Ritchie and Thompson received the National Medal of Technology from President Clinton in 1999 for their contributions.
  • Source Code Evolution:   - Steps include converting Source Code (Hello.cpp) to Object Code (Hello.obj) and finally to Executable Code (Hello.exe).

Exercises on Computer Basics and Program Design

  1. Fundamentals of a Computer System:    - Complete the sentence: A computer system is made up of __________ and __________.
  2. Basic Computer Architecture:    - List the four main parts.
  3. Role of Compiler:    - Explain what a compiler is used for.
  4. Programming Language Comparison:    - Discuss why high-level languages are easier than machine or assembly language.

Principles of Designing Programs

  1. Define the Problem: Write a clear statement of the problem.
  2. Inputs, Computation & Outputs: Determine necessary inputs, the computations to be performed, and expected outputs.
  3. Test Data Generation: Create test cases to validate the program.
  4. Algorithm Formulation: Write the algorithm using Pseudocode or a flowchart.
  5. Program Translation: Convert the algorithm into a coded program.
  6. Compilation and Testing: Compile the program, fix any bugs, and perform tests.

Algorithms

  • Definition: A well-defined method for solving a problem expressed through instructions for accomplishing a task.
  • Everyday Applications: Coding algorithms can be analogous to common activities (e.g., preparing a dish, building a computer).
  • Expression Formats: Algorithms can be represented as flowcharts or pseudocode.

Understanding Flowcharts

  • Flowchart Functionality: Uses graphical symbols to denote the flow of actions in a program.
  • Advantages: Quick comprehension due to visual representation.
  • Limitations: Inefficient for frequent modifications.
  • Example of Flowchart Process:   - Start → Read num → Display num → Decision: Is num < 0? → Output error if Yes.

Writing Algorithms in Pseudocode

  • Pseudocode for Age Calculation:   - Inputs: Name, Age (in Years)   - Computation:
        - Age in Months = 12imesextAge12 imes ext{Age}
        - Age in Days = 365.25imesextAge365.25 imes ext{Age}   - Outputs: Name, Age, and computed values.
Structure of Pseudocode
  • Major Steps Format:   1.0 Major Step 1
      2.0 Major Step 2
      3.0 Major Step 3

  • Detailed Description:   - As details are added, the format extends with sub-steps (e.g., 1.1, 1.2, etc.).

Top-Down Program Design

  • Description: A refinement process adding successive layers of detail to an algorithm.
  • Application: Simplifies the program translation process, helping structure the steps for coding effectively.
Example of Program Design for Triangle Area
  • Formula: Area = 0.5imesHimesB0.5 imes H imes B
  • Major Steps:   - Define Inputs: Two sides, H & B   - Define Computation: Area Calculation   - Define Outputs: Display area with the sides H & B
C++ Program Template
int main() {
    // statements;
}

Additional Exercises

  1. Define an algorithm.
  2. Apply design & development processes including pseudocode and flowcharts for:    - a program adding three integers.    - calculating the sum and difference of two whole numbers.    - a flowchart to find the smaller of two inputs.