Chapter 1 Part 1
Chapter 1 Part 1
Introduction
(Part 1)
CSC 128
FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
• Introduction to Programming
▫ What is a computer program
▫ Importance of computer program
▫ Importance of good program
▫ Relationship between compilers, interpreters,
assemblers and programs
Objectives
• In this chapter you will :
LOAD rate
MULT hour
STOR wages
Programming Languages Evolution
• Using high level language instructions, wages
= rates • hours can be written as:
#include <iostream.h>
int main()
{
int rates;
int hours;
int wages;
Software
Step-by-step instructions that tell the computer how
to do its work.
It is also called a program.
It’s purpose to convert data to useful information
Basic components of a computer
systems
SOFTWARE
SYSTEM SOFTWARE
• provides an environment for user
to execute the application APPLICATION SOFTWARE
software.
•Enables the application software • end user software.
to interact with computer •A program that performs a
hardware. common task to the user.
•Eg. Operating System •Eg. Word, Excel.
Main Hardware Component Categories
Main Hardware Component Categories
• Input Devices
▫ Is usually a keyboard where programs and data
are entered into the computer.
▫ Ex: mouse, pen/stylus, touch screen, audio input
unit
• CPU, Central Processing Unit
▫ Function is to execute instructions, such as
arithmetic calculations, comparisons among data,
and movement of data inside the system
Main Hardware Component
Categories
• Main memory/Primary Storage
▫ Is a place where the programs and data are stored
temporarily during processing.
▫ The data in primary storage are erased when you
turn off a personal computer or you log off from a
time-sharing computer
• Secondary Storage Devices
▫ It is the place where the programs and data are
stored permanently
Main Hardware Component
Categories
▫ When you turn off the computer, your programs
and data remain in the secondary storage ready f0r
the next time you need them
▫ Ex: Hard disk
• Output Devices
▫ Is usually a monitor or a printer where the output
will be shown.
▫ If the output is shown on the monitor; we say we
have a soft copy. if it is printed on the printer, we
say we have a hard copy.
▫ Ex: monitor, printer
Basic Operation in Computer
System
STORAGE
•Store the data or information for
future use (permanently or
INPUT temporarily)
•Whatever data that is PROCESSING •E.g. Hard disk, memory
inserted into a computer
using input devices •Convert input data into
•E.g. Mouse, keyboard information.
•E.g. CPU OUTPUT
•Generate the useful
information using output
devices
•E.g. Monitor, printer
Computer Program
• Program is a set of instructions that the computer needs to
follow to process the data into information.
• Programming Language contains set of instructions, data
and rules that are used to construct a program. Ex: C++, C,
VB
• Programming is the act of designing/writing and
implementing computer programs using the programming
languages.
• Programmer is a person who writes a computer program.
• Program’s Efficiency
▫ Good program should be reliable and efficient in the
sense that it is produces no errors during execution
process
▫ Program must achieve its purpose so that the final result
can be trusted
▫ Use of pseudocode or flowchart to outline the program
Good Programming Styles
• Interactivity
• Program readability
• Indent
▫ Line comment
Begin with two slashes (//)
Ex: //This is Line comment
▫ Block Comment
Begin with the symbol /* and end with the symbol */
Use for statements that span across two or more
lines
Ex: /* This program calculates the salary of
employees */
Example
// Programmer: Umi Hanim Mazlan line comment
#include <iostream.h>
{
--> cout<< “Hello world!\n”;
return 0; indent
}
Program Errors
• Also known as bugs
• Debugger (software tool) – trace through a
program to find bugs (logic errors)
• Can be divided into:
▫ Compile-Time errors or syntax error
detect by compiler
▫ Run-Time errors or logic
is detected when the program is being running
Program Errors (Cont…)
• Syntax errors
▫ Syntax error is an error in the structure or spelling of a
statement
▫ Can be detected by compiler
• Example
1 cout << “/n There are five syntax errors”
2 cot >> “Correct Them;
ASSEMBLER INTERPRETER
COMPILER
• a program that • a program that translates • a program that translates
translates the assembly high-level language into source code of high-level
language program into machine language. language into machine
machine language. •Translate the source code language.
once and saves to be reused. •Each instruction is
•Requires less memory and interpreted into machine
runs faster. language.
•Eg. PASCAL, C++, COBOL •Program is easier to develop.
•Eg. BASIC.
End of Chapter 1
(Part 1)