01 Introduction To Computers and Programming
01 Introduction To Computers and Programming
3
Computer Systems
◙ Computer systems consist of two main components:
◘ Hardware devices and
◘ Software components
4
Computer Hardware Component Categories
◙ Hardware refers to the physical components of which a computer is
made. A computer is not an individual device, but a system of devices.
◙ A typical computer system consists of the following major hardware
components:
1. Central Processing Unit (CPU)
2. Main Memory
3. Secondary Memory / Storage
4. Input Devices
5. Output Devices
5
Computer Hardware
7
CPU Organization
9
Main Memory (2 of 2)
◙ In Figure-3, the number 149 is stored in the byte with the address 16, and the
number 72 is stored at address 23.
Figure-3: Memory 10
Secondary Storage
◙ Secondary storage is a type of memory that can hold data for long
periods of time, even when there is no power to the computer
◙ Secondary storage is non-volatile. Data and / or programs retained
when computer is turned off
◙ Programs are normally stored in secondary memory and loaded into
main memory as needed.
◙ Secondary storage comes in a variety of media:
◘ magnetic: traditional hard drives that use a moveable mechanical arm to
read/write
◘ solid-state: data stored in chips, no moving parts
◘ optical: CD-ROM, DVD
◘ Flash drives, connected to the USB port
11
Input Devices
◙ Input is any data the computer collects from the outside world
◙ Input Devices that send information to the computer from outside
◙ Many devices can provide input:
◘ Keyboard, mouse, touchscreen, scanner, digital camera, microphone
◘ Disk drives, CD drives, DVD drives, and USB drives can also be
considered input devices because programs and information are retrieved
from them and loaded into the computer’s memory.
12
Output Devices
◙ Output is any information the computer sends to the outside world. It
might be a sales report, a list of names, or a graphic image.
◙ The information is sent to an output device, which formats and
presents it.
◙ Common output devices are :
◘ screens, printers, plotters and speakers.
◘ Storage devices (like Disk drives, CD drives, DVD drives, and USB
drives) can also be considered output devices because the CPU sends
them data to be saved.
13
Software or Programs
◙ Everything a computer does, from the time you turn the power switch
on until you shut the system down, is under the control of software.
◙ There are two general categories of software:
◘ System software: programs that control and manage the basic operation
of a computer hardware and the programs that run on them.
■ Examples: operating systems, utility programs, Compilers and software
development tools
◘ Application software: programs to solve specific problems that provide
services to the user and make a computer useful for everyday tasks.
■ Examples : word processing, presentation program, spreadsheet programs,
e-mail programs, web browsers, and game programs.
14
Programs and Programming Languages
(1 of 2)
15
Example Algorithm for Calculating Gross Pay
16
Machine Language (1 of 2)
◙ Although the previous algorithm defines the steps for calculating the
gross pay, it is not ready to be executed on the computer
◙ The computer only executes machine language instructions
◙ Machine language instructions are binary numbers (numbers
consisting of only 1s and 0s)
◙ The binary numbers form machine language instructions, which the
CPU interprets as commands. Following is an example of what a
machine language instruction might look like:
1011010000000101
17
Machine Language (2 of 2)
C++
BASIC Ruby
FORTRAN
Java
Visual Basic
COBOL
C# Swift
Rust JavaScript
C Python Go
Figure-5: High-level Programming languages
From a High-Level Program
to an Executable File (1 of 2)
23
Integrated Development Environments
(IDE) (2 of 2)
27
Key Words (2 of 2)
Programmer-Defined Identifiers
◙ Programmer-defined identifiers - Names made up by the programmer
◙ Programmer-defined identifiers are not part of the C++ language
◙ Used to represent various things: variables (memory locations),
functions, etc.
◙ In previous C++ Program: hours, rate, and pay are Programmer-
defined identifiers.
29
Operators (1 of 2)
30
Operators (2 of 2)
Punctuation (1 of 2)
32
Punctuation (2 of 2)
Syntax
◙ The rules of grammar that must be followed when writing a program
◙ Controls the use of key words, operators, programmer-defined
symbols, and punctuation
34
Variables
◙ A variable is a named storage location in the computer’s memory for
holding a piece of data.
◙ In previous C++ Program, we used three variables:
◘ The hours variable was used to hold the hours worked
◘ The rate variable was used to hold the pay rate
◘ The pay variable was used to hold the gross pay
35
Variable Definitions (1 of 3)
◙ Here is the statement from previous C++ Program that defines the
variables:
36
Variable Definitions (2 of 3)
◙ There are many different types of data, which you will learn about in
this course.
◙ The variable definition specifies the type of data a variable can hold,
and the variable name.
37
Variable Definitions (3 of 3)
• The word double specifies that the variables can hold double-
precision floating point numbers.
38
Input, Processing, and Output
Three steps that a program typically performs:
◙ Gather input data:
◘ from keyboard
◘ from files on disk drives
◙ Process the input data
◙ Display the results as output:
◘ send it to the screen
◘ write to a file
39
The Programming Process
◙ The programming process consists of several steps, which include
design, creation, testing, and debugging activities.
◙ Figure-8 showing the steps recommended for the process of writing a
program.
40
The Programming Process
42