Note

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

Chapter

bath processing
Mum
>Out
>
Processing -
-

tion)

-
Computer Software
computer program/program
computer software

- ·
APPLICATION
SOFTWARE
SYSTEM
SOFTWARE
Dur Replication
a

>
-

develop to solve >


-

provides a convenient -y
specific
oering
a
problem environment for development
uegram
>
-

Spreadsheet (EXcel) >


-

Operating system
(Windows , UNIX LINUX
,

>
-

Databaseapplication >
-

Manslator
(Ms Access)
A to
pseudocode write

① A computer can receive information.


& information
A
computer can
put out .

② A
computer can perform arithmetic
④ A computer can
assign a value to a variable or
memory location .

⑤ A computer can
compare two variables and select one of two alternate actions .
⑧ A computer can repeat a
group
of actions -

③ Example perform arthmetic :


-

add number to total OR


=
-

Total Total + number

Symbols can be written in


pseudocode :

- add
-

subtract

*
multiply
I divide

1) for parentheses

① Example memory location

verbs Initialise used to data initial value


or set give an
-

symbols' - '' used to value result


assign a as
-

a
or

verbs Save or store used to keep a variable

⑨ Example two variables & select one

-
to represent operatin in pseudocode
used : IF
,
THEN and
ELSE
-

to companson
used : If

the choice of alternatives


-

used : THEN Or ELSE

⑧ Example repeat a
group
of actions
-

repeat (loop)
used :
DOWHILE /ENDDO
2 .
2
Meaningful Names

-variable/identifier
-

names should be
meaningful
-

names should be transparent to


adequately describe variables
(Number 1
,
number 2 , etc)

Quiz >
-

during lab (week 6)

Mek < >


-

TEST (LAB SESSION)


Relational Operators
&

operator
condition Example
&

Is
equal to (or "is the same as" ( = int i =
1 ; (i = =
1)

Is not to Cor "is not the ! int i 2 ; (i ! z)


equal = =

same as " (

less than int i 0 ; (i 1)


Is L = <

Is less than or equal to E


inti =
1 ; (i <=
1)

Is greater than 7 int i = 2 ; (i < 1)

Is greater than to 7 inti 1 (i) 1)


equal ;
= =
or

2nditional
Operators

operation
operator
Example

If one condition AND another condition int i =


2 ;

intj 8 ; =

((i < 1) &S(j >


6)

If either one condition OR another condition I int i = 2


;
int j = 8 ;
((i < 1) 1 (j <
10)

NOT ↓ int i =
2 ;
( ! (ias)

Evaluate the
following Boolean expression

i
2014
I
.
2015 >=

ii . ! (12 <
6)
iii. 8 ! =
8 =
F

ir
int bS
. ,

= T

bc =
c A8( = = 6
5 6 6
T
T =
T
ControlStructureaetements
-election -

① if statement
* single-selection statement

& it .... elsestatement


* double-selection statement

③ switch statement
*
multiple-selection statement

#
single-selection statementconventact
Craviable # 0 . value
output

↓ ↓ Y
& PSEUDOCODE Student Grade > =
60

If student's grade greater than to


is or equal 60 THEN

ENDIF

If the condition is false


,
the
print statement is ignored ,
and the next

pseudocode statement in order is performed .

② Java code :

if (student Grade z =
60)
printin ("Passed"
(;
system . out

& Flowchart :

200
=.... else Double-selection Statement

① PSEUDOCODE
If student's grade is greater than or
equal to 60 THEN

Print "passed"
ELSE

Print "Failed"
ENDIF

if the condition is false ,


the print statement is ignored ,
and the next

is
Pseudocode statement in order performed .

② Java code :

if (student Grade >= 60 (


system .
Out .

print in "Passed" ( ;

else Nested if .... else statements


system . out .
printin )"Failed" ) ;

Sightax
if (boolean expression (
statement (s) ; 11 The

else
statement (s) ; 11 False

③ Flowchart

espy
Student Grade = 60 Eee
"passed"

I T En
False

or

Display" Failed"

↓ OR

#
-

+ 1
Switch Statement (case) if (v RO v
Another of doing the if .... else statement the switch
way is
by using
command . This is a better of doing if else if it involves
way a
....

complex nested if .... else statement -

Syntax
:
Pseudocode :

Switch (variable ( CASE OF variable :

E value -
1 :
Statement block - 1

case value 1 : statement (s) ; value - 2 :


Statement block -
2

break ; -

value 2 Statement (s)


;
:
·

case

break ; statement block


value -n
: -
n

default : statement (s) ; value -


other : statement block -
other

3 ENDCASE

You might also like