0% found this document useful (0 votes)
14 views

01 CS1 Unit 2 - Lesson 1

This document provides an overview of computer systems, detailing the components of hardware and software, and their roles in processing data through input, processing, and output operations. It also discusses programming languages, syntax, memory storage, and the importance of algorithms in program logic. Additionally, it highlights the distinction between syntax and logical errors in programming, emphasizing the necessity of correct sequencing in instructions.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

01 CS1 Unit 2 - Lesson 1

This document provides an overview of computer systems, detailing the components of hardware and software, and their roles in processing data through input, processing, and output operations. It also discusses programming languages, syntax, memory storage, and the importance of algorithms in program logic. Additionally, it highlights the distinction between syntax and logical errors in programming, emphasizing the necessity of correct sequencing in instructions.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

CS 1 – Programming

Logic Formulation
Unit 2: Computers and Programming
Lesson 1: Computer System, Program Logic and Algorithm
Computer System
Understanding Computer Systems

• A computer system is a combination of all the


components required to process and store data using
a computer. Every computer system is composed of
multiple pieces of hardware and software.
Hardware
• is the equipment, or the physical devices, associated
with a computer. For example, keyboards, mice, speakers,
and printers are all hardware. The devices are
manufactured differently for large mainframe
computers, laptops, and even smaller computers that
are embedded into products such as cars and
thermostats, but the types of operations performed
by different-sized computers are very similar.
Software
• is computer instructions that tell the hardware what to
do. Software is programs: instructions written by
programmers. You can buy prewritten programs that are
stored on a disk or that you download from the Web.
For example, businesses use word-processing and
accounting programs, and casual computer users enjoy
programs that play music and games. Alternatively, you
can write your own programs. When you write software
instructions, you are programming.
Three Major Operations
• Together, computer hardware and software
accomplish three major operations in most
programs:
1) Input
2) Process
3) Output
Input
• Data items enter the computer system and are put
into memory, where they can be processed.
Hardware devices that perform input operations
include keyboards and mice. Data items include
all the text, numbers, and other information that are
processed by a computer.
Process
• Processing data items may involve organizing or
sorting them, checking them for accuracy, or
performing calculations with them. The hardware
component that performs these types of tasks is
the central processing unit, or CPU.
Output
• After data items have been processed, the resulting
information usually is sent to a printer, monitor, or
some other output device so people can view,
interpret, and use the results.

• Computation
Input Data Process • Checking Output Information
• Sorting
Programming Language

•You write computer instructions in a


computer programming language, such as
Visual Basic, C#, C++, or Java. Just as some
people speak English and others speak
Japanese, programmers also write programs in
different languages.
Syntax
• Every programming language has rules governing
its word usage and punctuation. These rules are
called the language’s syntax. If you ask, “How the
geet too store do I?” in English, most people can
figure out what you probably mean, even though
you have not used proper English syntax—you
have mixed up the word order, misspelled a word,
and used an incorrect word.
Memory
• When you write a program, you usually type its instructions
using a keyboard. When you type program instructions, they are
stored in computer memory, which is a computer’s temporary,
internal storage. Internal storage is volatile—its contents are
lost when the computer is turned off or loses power. Usually,
you want to be able to retrieve and perhaps modify the stored
instructions later, so you also store them on a permanent
storage device, such as a disk. Permanent storage devices are
nonvolatile—that is, their contents are persistent and are
retained even when power is lost.
Compiler and Interpreter
• After a computer program is stored in memory, it
must be translated from your programming
language statements to machine language that
represents the millions of on/off circuits within
the computer. Each programming language uses a
piece of software, called a compiler or an
interpreter, to translate your program code into
machine language.
Machine Language
• Machine language is also called binary language,
and is represented as a series of 0s and 1s. The
compiler or interpreter that translates your code
tells you if any programming language component
has been used incorrectly. Syntax errors are
relatively easy to locate and correct because the
compiler or interpreter you use highlights every
syntax error.
Program Logic and Algorithm
Understanding Simple Program Logic
• A program with syntax errors cannot execute. A
program with no syntax errors can execute, but might
contain logical errors, and produce incorrect output as
a result. For a program to work properly, you must give
the instructions to the computer in a specific sequence,
you must not leave any instructions out, and you must
not add extraneous instructions. By doing this, you are
developing the logic of the computer program.
Simple Logic

•Suppose you instructed someone to heart


your photo in a photo contest:

Click the original photo


Click heart emoji
Share with friends
Logical Error
• Even though you have used the English language syntax
correctly, the cake-baking instructions are out of
sequence, some instructions are missing, and some
instructions belong to procedures other than baking a
cake. If you follow these instructions, you are not going
to make an edible cake, and you most likely will end up
with a disaster. Logical errors are much more difficult
to locate than syntax errors.
Sample Logical Error
Algorithm
• Most simple computer programs include steps or
algorithm which is the sequence of steps necessary to
solve any problem. Suppose you want to write a
computer program to double any number you provide.
This sequence of steps in Pseudocode will solve your
problem: Step 1: Input Number
Step 2:
Multiply
Number by
2 Step 3: Output
• The instruction to input myNumber is an
example of an input operation. When the
computer interprets this instruction, it knows to
look to an input device to obtain a number. When
the number is retrieved from an input device, it is
placed in the computer’s memory at the location
named myNumber. The location myNumber is a
variable. A variable is a named memory location
whose value can vary.
• The instruction set myAnswer = myNumber * 2
is an example of a processing operation.
Mathematical operations are not the only kind of
processing operations, but they are very typical.
The output myAnswer instruction is an example
of an output operation. Within a particular
program, this statement could cause the output to
appear on the monitor
REVIEW OF TODAY’S
DISCUSSION
1. What are the THREE MAJOR OPERATIONS?
2. What do you call an equipment, or the physical devices,
associated with a computer?
3. A computer instructions that tell the hardware what to do?
4. Examples of programming language?
5. What most simple computer programs includes which is the
sequence of steps necessary to solve any problem?
INPUT
PROCESS
OUTPUT
LITTLE REVIEW OF TODAY’S
DISCUSSION
1. What are the THREE MAJOR OPERATIONS?
2. What do you call an equipment, or the physical devices,
associated with a computer?
3. A computer instructions that tell the hardware what to do?
4. Examples of programming language?
5. What most simple computer programs includes which is the
sequence of steps necessary to solve any problem?
HARDWARE
LITTLE REVIEW OF TODAY’S
DISCUSSION
1. What are the THREE MAJOR OPERATIONS?
2. What do you call an equipment, or the physical devices,
associated with a computer?
3. A computer instructions that tell the hardware what to do?
4. Examples of programming language?
5. What most simple computer programs includes which is the
sequence of steps necessary to solve any problem?
SOFTWARE
LITTLE REVIEW OF TODAY’S
DISCUSSION
1. What are the THREE MAJOR OPERATIONS?
2. What do you call an equipment, or the physical devices,
associated with a computer?
3. A computer instructions that tell the hardware what to do?
4. Examples of programming language?
5. What most simple computer programs includes which is the
sequence of steps necessary to solve any problem?
Visual Basic, C#, C++, or Java
LITTLE REVIEW OF TODAY’S
DISCUSSION
1. What are the THREE MAJOR OPERATIONS?
2. What do you call an equipment, or the physical devices,
associated with a computer?
3. A computer instructions that tell the hardware what to do?
4. Examples of programming language?
5. What most simple computer programs includes which is the
sequence of steps necessary to solve any problem?
Algorithm
End
Up next...
Unit 2: Computers and Programming
Lesson 2: Program Development Cycle, Pseudocode
Statements and Flowchart Symbols

You might also like