Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

CHAPTER 1

Introduction to Computers and


Programming
What is Computer
It is a programmable machine
designed to follow instructions

What is a program?
A program is a set of instructions that a computer follows to
perform a task.

Who is a programmer?
A programmer , or software developer , is a person
with the training and skills necessary
to design, create, and test computer programs.

SO, without programmers, no programs;

Without programs, the computer cannot do anything


Computer Systems

Hardware Software

System Applications
Central Main Secondary Input Output Software
Process memory storage Devices Devices
(RAM) devices
ing Unit
(CPU)
Operating Utility Software
systems Programs Development
Tools
1-Central Processing Unit (CPU)
Control Unit
• Retrieves and decodes
program instructions
• Coordinates computer
operations

Arithmetic & Logic Unit (ALU)


• Performs mathematical
operations.
• Performs logical operations
(eg, comparisons).

Processor speed is measured


currently in gigahertz (GHz)
2- Main Memory
Holds both program instructions and data

Volatile – erased when program terminates


or computer is turned off
Also called Random Access Memory
(RAM)

It is divided into bytes. One byte is


enough memory to store only a letter of the alphabet or a small number

Each byte is assigned a unique number known as an address .


3-Secondary Storage

Non-volatile - data retained when program is not running or computer is turned off

Comes in a variety of media


magnetic: floppy or hard disk drive, internal or external
optical: CD or DVD drive
flash: USB flash drive
4-Input Devices
Used to send information to the
computer from outside
Many devices can provide input
keyboard, mouse, microphone,
scanner, digital camera, disk drive,
CD/DVD drive, USB flash drive

5-Output Devices
Used to send information from the
computer to the outside
Many devices can be used for output
Computer screen, printer, speakers,
disk drive, CD/DVD recorder, USB
flash drive
Software:
1- Operating systems
Programs that manage the computer
hardware and other programs that run on the
computer, like Windows, macOS, Linux.
2- Utility programs
Programs that enhance computer’s operations like virus canners, data
backup programs.

3- Software development tools


Programs that programmers use to create, modify, and test developed
programs.

4-Applications
Programs that make a computer useful for everyday tasks, these
include word processing programs, games, web browsers, …etc.
Programming Language
a language used to write programs
Types of languages

Low-level: used for


High-level: closer to
communication with
human language
computer hardware
directly.
Python C# Java
FORTRAN C++ COBOL

Pascal
How can we write programs in High-level
languages, and computer can still understand
them?
1- Compiler is a software that translates high level programs into machine language
(ML) instructions.

2- Interpreter is a software that translates


and executes high level programs, it reads
each individual instruction, converts it to
machine language instructions, and
immediately executes them.
Algorithm
An algorithm is a procedure or formula for solving a problem.
The word derives from the name of the mathematician,
Mohammed ibn-Musa al-Khwarizmi, who was lived in
Baghdad from about 780 to 850.

An algorithm is a set of well-defined steps for performing a


task or solving a problem.
Example of algorithm(average of two numbers).
1.Display a message on the screen “Enter first number?”

2. Wait for the user to enter a number. Once the user enters a
number, store it in memory in a variable call it X

3. Display a message on the screen “Enter second number?”

4. Wait for the user to enter a number. Once the user enters
a number, store it in memory in a variable call it Y

5. Calculate total of X and Y in a variable call it S


S=X+Y
6. Calculate the average in a variable call it A
A=S/2
7.Display a message on the screen “The average=” and
display the value of A

The above instructions are called an algorithm.

Notice these steps are sequentially ordered. Step 1 should


be performed before step 2, and so forth. It is important that
these instructions be performed in their proper sequence.
Same algorithm (more formal)
1.Start
2. Print “Enter the first number”
3. Read x
4. Print “Enter the second number”
5. Read y
6. s=x+y
7. a=s/2
8. Print a
9. End
Algorithm to calculate area of a rectangle
1.Start
2. Print “Enter the length”
3. Read x
4. Print “Enter the width”
5. Read y
6. a=x*y
7. Print a
8. End
Challenges
Write an algorithm to calculate the area of a square

Write an algorithm to calculate the area of a circle

Write an algorithm to read a salary of an employee and


deduct 15% as a tax, then display the net salary
Flowcharts
Both algorithm and flowchart describe how to carry out a
process
Algorithm uses normal language to describe a step-by-step process on
how to solve the problem

Flowchart uses symbols to describe steps of the solution.

Computer programmers use flowchart to describe the “flow” of a


program.
Flowchart Notations:
Symbol Its meaning

Start or end of the program

Computational steps or processing

Input or output operation

Decision making and branching

Connector or joining

Arrows represent the sequence and direction of a


program.
Algorithm and Flowcharts
1.Start
2.Print “Enter the first number”.
3.Read X
4.Print “Enter the second number”.
5.Read Y
6.T=X+Y
7.A=T/2
8.Print A
9.End
Output
Input
operations
operations

Computational
process

You might also like