Chapter 1: Introduction to Computers and Programming

Introduction to Computers and Programming

1. 1 Introduction

  • Computers are used in various settings:

    • School: Writing, research, email, online classes.

    • Work: Analyzing data, presentations, business transactions, communication, machine control.

    • Home: Paying bills, online shopping, communication, games.

  • Devices that are computers:

    • Smartphones

    • MP3 Players

    • Tablets

    • Car navigation systems (GPS)

  • Computers execute tasks based on program instructions.

  • A program is a set of instructions for performing a task (e.g., Microsoft Word, PowerPoint).

  • Programs are also called software.

  • Programmers or Software Developers:

    • Create computer software.

    • Design, create, and test programs.

1. 2 Hardware and Software

  • Hardware: Physical components of a computer.

  • Software: Programs that run on a computer.

  • A computer is a system of devices working together.

  • A Computer System consists of:

    • Central Processing Unit (CPU)

    • Main memory

    • Secondary storage

    • Input devices

    • Output devices

Central Processing Unit (CPU)
  • Runs programs, often called the processor.

  • A computer cannot run software without a CPU.

  • Running/executing a program: the computer performs the program's tasks.

  • ENIAC:

    • The world’s first programmable computer, built in 1945.

    • Designed to calculate artillery ballistic tables.

    • The CPU was 8 feet tall, 100 feet long, and weighed 30 tons.

  • Microprocessors:

    • Much smaller and more powerful than earlier CPUs.

Main Memory
  • The computer’s work area.

  • Stores running programs and data.

  • Random-access memory (RAM) allows quick data access.

  • RAM is volatile memory, used for temporary storage and is erased when the computer is turned off.

  • Read-Only Memory (ROM):

    • The computer can read ROM's contents but not change or add data.

    • ROM is nonvolatile; it retains its contents even when power is off.

    • Stores critical system programs, like the startup program.

Secondary Storage Devices
  • Stores data for long periods.

  • Stores programs and important data like disk drives.

  • Disk drive:

    • Stores data magnetically on a circular disk.

    • Internal and external disk drives are available for backup copies.

  • Solid-State Drives:

    • Stores data in solid-state memory without a disk.

    • Faster operation due to no moving parts.

  • USB Drives:

    • Small devices plugging into the USB port.

    • Data stored on flash memory.

    • Also known as memory sticks or flash drives, they are inexpensive and reliable.

  • Optical Devices (CD/DVD):

    • Data encoded as pits on the disc surface using a laser.

    • Holds large amounts of data, suitable for backups.

  • Cloud Storage:

    • Stores data on remote servers, accessible via the internet or private networks.

    • Accessible from various devices with a network connection.

    • Used for backing up data stored on a computer’s disk.

Input Devices
  • Collect data from people and other devices.

  • Common input devices:

    • Keyboard

    • Mouse

    • Touchscreen

    • Scanner

    • Microphone

    • Digital camera

Output Devices
  • Present data to people or other devices.

  • Common output devices:

    • Monitor

    • Printer

Software
  • Controls everything a computer does.

  • Two categories:

    • System software

    • Application software

System Software

  • Manages basic computer operations.

  • Includes:

    • Operating System: Controls hardware and manages devices.

    • Utility Programs: Enhance computer operation or safeguard data.

    • Software Development Tools: Used to create, modify, and test software.

Application Software

  • Programs used for everyday tasks.

  • Examples:

    • Word processing

    • Spreadsheet

    • Database

    • Presentation software

1. 3 How Computers Store Data

  • All data is converted to sequences of 0s and 1s.

  • A computer’s memory is divided into bytes.

  • One byte represents one number.

  • A byte is divided into eight bits (binary digits).

  • Bits are electrical components holding a positive or negative charge.

  • Positive charge: on position (1).

  • Negative charge: off position (0).

Storing Numbers
  • Positive charge (on): represented by 1.

  • Negative charge (off): represented by 0.

  • Corresponds to the binary numbering system.

  • Each digit in a binary number has a value assigned to it according to powers of 2.

  • The largest value that can be stored in a byte (eight bits) is 255.

  • Two bytes can be used for larger numbers; the maximum value is 65535.

Storing Characters
  • Characters are stored as binary numbers.

  • ASCII (American Standard Code for Information Interchange) is a coding scheme.

  • The letter A is stored as the number 65.

  • ASCII is a set of 128 numeric codes.

  • ASCII is limited as Unicode is an extensive encoding scheme.

  • Unicode is compatible with ASCII and represents characters for many languages.

Advanced Number Storage
  • The binary system can represent integer numbers.

  • Negative numbers are encoded using two’s complement.

  • Real numbers are encoded using floating-point notation.

Other Types of Data
  • Digital data: data stored in binary.

  • Digital device: any device working with binary data.

  • Digital images: composed of pixels (picture elements).

  • Digital sound: broken into samples.

1. 4 How a Program Works

  • A computer’s CPU understands machine language.

  • People use other programming languages because machine language is difficult.

  • The CPU is the most important component in a computer that is designed to do specific things.

  • CPU is designed to perform the following operations:

    • Read data from main memory

    • Adding two numbers

    • Subtracting numbers

    • Multiplying numbers

    • Dividing numbers

    • Moving data between memory locations

    • Determining equality of values

  • CPU understands machine language consisting of 1s and 0s.

  • The CPU's instruction set: the entire set of instructions the CPU can execute.

  • Each microprocessor brand (Intel, AMD, Motorola) has a unique instruction set.

  • Fetch-decode-execute cycle: the CPU executes instructions in three steps.

    • Fetch

    • Decode

    • Execute

From Machine Language to Assembly Language
  • Computers only understand machine language.

  • Writing machine language is difficult.

  • Assembly language uses mnemonics (short words).

  • An assembler translates assembly language to machine language.

High-Level Languages
  • Assembly language is a low-level language.

  • High-level languages:

    • Allow the creation of powerful programs without CPU knowledge.

    • Use easier to understand words such as Java, C++, Python, Visual Basic, Ada, C#, Fortran.

Key Words, Operators, and Syntax: an Overview
  • Key words (reserved words): have specific meaning.

  • Operators: perform operations on data.

  • Syntax: rules to be strictly followed when writing a program.

  • Statements: individual instructions.

Compilers and Interpreters
  • Statements in a high-level language are source code or code.

  • Source code is translated to machine language using a compiler or interpreter.

  • Syntax error: mistakes like misspelled words, missing punctuation, or incorrect operator use.

  • Compiler: translates a high-level program into a separate machine language program.

  • Interpreter: translates and executes instructions in a high-level program

1. 5 Types of Software

  • Programs generally fit into one of two categories

    • System Software - Programs that control or enhance the operation of a computer such as an Operating System, Utility Programs, or Software Development Tools

    • Application Software - Programs that make a computer useful for every day tasks such as Microsoft Word, email programs, and Web browsers.