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

Computer

Uploaded by

hotonhoton123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Computer

Uploaded by

hotonhoton123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Introduction

To

Programming
Is two 50,4 *

*③ § +381%-6%6 *

§ 's >
CHI 01
e

Introduction to programing

- Some problems are easy -


other problems are complex
Example making
: a Cup of coffee Example stay : for a month in Dammam

in the morning . with limited budget 2000 SR


(accommodation food , , transportation , .
.
. )

* computer is very powerful which can help you to solve some of the problems
that you encounter .

Types of problems
* problems don't always have staight forward solutions .

-
Some problems ,
sash as balancing a checkbook or baking a cake ,
can be solved with a

series of actions .
These solutions are called Algorithmic solutions .
.me , o-G.tw

-
The solutions of other problems ,
sash as how to buy the best stock or whether to expand

the company ,
are not straightforward .

-
solutions that cannot be reached through a direct set of steps are called

Heuristic solutions _.mgéI .


problem solving with computers
b

Solution : the instructions listed Results the outcome


: or the Program Set : of

that enables you to solve a problems . answer . instructions that make

up the solution .

* computer are built to deal with algorithmic solutions which are often ,
difficult for humans .

* People are better than computers at developing heuristic solutions .

* the field of computers that deals with heuristic types of problems is called

artificial intelligence .

programing languages
programming languages : is the median of communication between you

and a computer system .


( coding )

( ⑥ Ww Hewell ( machine Language ,


machine code ) : is the only language that can be

Understood by the computer .

Advantages Disadvantages


executed directly .
-
difficult to use and understand .

-
( 0,1 ) .
-
Machine dependent .


doesn't require translator . -
difficult to find errors , debug

takes less time .
and modify .

-
first generation language .

-
closer to the computer .
Middle level ( assembly language ) :

- are created using symbols sash as letters , digits and special special characters .

-
We Use words called mnemonics , and there are different mnemonic for diffrent

computers architectures .

-
needs a trans later called assembler to

translate mnemonics into machine code .

-
assembly code Example : SUB AX, ,
BX

-
mnemonics Example : ADD MOV SUB
, ,

Advantages Disadvantages

- Writing in assembly is easier •


Machine dependent
than machine code .
-
needs to be translated

- assembly is more readable . -


Assembly is slower

-
easy to understand .


easy to find errors , modify .
High level :

-
similar to human language grammer rules .

-
Can be understood by the User .


has a set of predefined words known as keywords and set of rules known

as syntax to create instructions .

-
needs to be translated by compilers and inter p renters .

-
Example : JAVA C++ BASIC
, ,

Advantages Disadvantages

-
Writing instructions is easier . -
needs to be translated .

-
readable and understandable -
slower than the others .

than the others .

- runs on different Mackins Whith

change or not .


easy to Understand .

-
easy to creat programs .

-
✗ to find errors and modify .

-
closer to the User .

Part one
Done
Ch 't
'
2

Program Development Life cycle

program development Life cycle PDLC :


is the process of developing a software by
following a basic set of interrelated procedures .

The basic set of procedures that are followed in the program development are as follows :

- Analyzing the problem .

-
Algorithm Design and Representation .

-
implementation ( coding ) .

-
Testing .

- Documentation .

Analyzing the problem

The analysing stage allows software developers to understand and analyse the requirements of

the problem in more detail .

The most common practice is descussed is :


Input -

processing -

output chart 0

the Input -

processing -
output ( 1Pa

the IPO chart organizes information about a problem in detail sash as :

-
What data items are input .

-
what processing takes place on that data .

-
what information will be the result that is the output .

-
Shows where in the solution the processing takes place .

* the output is the first to be completed ,


then input and the last ,
is processing .

>
* OH djj.WS 81 *
IPO chart for the wage

calculation problem given as :

input processing output


Number of hours ← Enter Hours -
Employee
worked NH .
Worked .

Wage .

__
Hourly pay Rate £ Enter pay Rate .

RP . -3 Calculate wage .

* print wage .

§ End .

Dart two
Done
CHI 03

Algorithm design and representation

Algorithm : is one common problem solving technique includes analayaing

a problem outlining the problem requirements


,
and designing steps to solve problems .

-
It's defined as step by step process to get a solution in less time .

-
the most ways to represent an algorithm are preudo code and flowchart .

pseudocode

pseudocode : is an abstract form of a program .

Pseudocode consists of : mixture of english statements , mathematical notation ,


selected

keywords from a
programming language .

* it dos en 't Use


any graphical representation .

Advantages :
easy to read , understand ,
and modify .

v. [email protected] -4*6 *

flowchart
flowchart : is defined as a step by step diagrammatic representation of the logic paths
to solve a problem .

Flowchart consists of : terminator boxes process boxes , ,


and decision boxes .

* it's a visa or graphical representation of an algorithm .

* when we translated into a computer Language it ,


will be a complete program .

Advantages :

it shows the logic of a problem ,


which is make it easier to checking what is wrong .

is a
good way to communication between users .

it allows the problem solver to break the problem into parts to make a master chart .
Symbols

Terminal symbol nput -


output symbol

it's the beginning and it's an input -

output opre ration .

end of an algorithm statements like input ,


read ,
print

are represented by this symbol .

Process symbol Decision ,


selection symbol
it shows any set of used to test conditions or ask questions
processing
operation or instruction except and depending upon the answer , appropriate
input -
output -
selection .
actions are taken by the computer .

Example storing
: arithmetic operations .

flow lines symbol on page connector symbol


indicate the execution steps it used to join different parts of

in the algorithm .

every line must a flowchart on a same page .

have an arrow on it to indicate

in any direction .

off page connector

it means where the algorithm ends on the first

page and where it continues on the second page .

Part Three → [email protected] *

Done •
Chi .
oy

Algorithm structure
any algorithm can be described using only three control structures :

control structure
"

1.
"

sequence .

selection control structure


"

2.
"
.

"

Repetition control structure


"

3. .

* you may have more than one control structure in one program

"

sequence control structure


"

* it's the most commonly used and simplest .

* we should put the instructions in sequnce from the tob to the bottom .

* all the problems use the sequential structure .

v. His -4.6 Qb , Wii *

"

selection control structure


"

* it can be used when you want the computer to choose between alternative actions .

* you make an assertion if it's true


.
,
the computer executes on statement .
if it's false ,
it executes another .

selection control structure has derided two Mutiple


* into a three main types : one
ways selection
.

,
,

> * Js # A -6.6%6 *

Relational operators

Equl To → a ==b ,
Not Equal To → a 1. = b

Greater than → a > b .


Greater than or equal to → a > = b

Less than → a < b .


Less than or equal to → a < = b

Logical operators
part four And → && ,
OR → ( two vertical bars)
Done . .

Not → ! we j.wb.io *

> * ③ I
CHI 05

Repetition structure
" "

control

constructing repetitive sections of code requires four elements :

1. A repetition statement it controls whether the code will be executed or not .


there are three

different forms of repetition structure : Do -


While structure , for structure ,
and Do -
Until structures

2. A condition that needs to be evaluated .


if the condition is true ,
the code is executed .
if it's false ,

the code is not executed .

3. A counter initialization statement that initially sets the condition and it must , always be placed

be for the condition is first evaluated .

4. A counter update statement within the repeating section of code that allows the condition to become false .

pretest and posttest loops

* the condition being tested either at the end beginnign or the end .

* the following it's a test accures at the begging of the loop .

* this type of loop is referred to as a pretest loop ,


because the condition is tested before any

statements within the loop are executed .

* if it's true ,
the executable statements within the loop are executed .
if it's false ,
the executable statement

within the loop are never executed ,


and control trasfers to the first statement after the loop .

* the pretest loops are referred to as entrance - controlled loops .

Both the while and for loop are examples of sushi loops .

While pretest loop


" "

we can't execute any loop before the

condition is evaluated ,
because the condition

is evaluated at the beginning of the loop .

v. Us # A jj.WS I *

You might also like