Vous êtes sur la page 1sur 10

INTRODUCTION

What is pseudo code? Pseudo code is an informal high-level description of the operating
principle of a computer program or other algorithm. It uses the structural conventions of a programming
language, but is intended for human reading rather than machine reading. Pseudo code typically omits
details that are not essential for human understanding of the algorithm, such as variable declarations,
system-specific code and some subroutines. The purpose of using pseudocode is that it is easier for
people to understand than conventional programming language code.
Flow chart also must be contructed in making a program. Flowchart is a diagrammatic
representation of an algorithm. Flowchart are very helpful in writing program and explaining program to
others. Different symbols are used for different states in flowchart, For example: Input/Output and
process has different symbols. Though, flowchart are useful in efficient coding, debugging and analysis
of a program, drawing flowchart in very complicated in case of complex programs and often ignored.
When completing this task I also used a lot of operators not only the common operators like
plus, mines, multiplication and divison. There is new operators that I learn which called as increment
and decrement operators. This operator are unary operators that add or substract one from their
operand, respectively. The encrement operator is written as ++ and the decrement operator is written
as --. The increment value increases the value by 1. Similiarly, the decrement value of its modifiable
arithmethic operand by 1.





1. CONSRUCT A FLOW CHART BASED ON THE PSEUDO CODE BELOW:

Pseudo Code : To start up the car engine
1. Start
2. Insert key
3. Free gear.
4. Turn the key to starting position (start)
5. If the engine started within 6 seconds, release the key to ON position
6. If the engine not started after 6 seconds, repeat step 4 until 6 (but more than 5 trial time)
7. If exceed than 5 trial times, call for workshop.
8. End



















start
Insert key
Free gear
Turn key
Engine
start < 6
second
end
Try > 5
Call workshop
No
No
Yes
Yes
2. Calculate the remaining salary for an employee after being deducted to the tax imposed
a. What the suitable input for the problem?
The salary of an employee

b. What will be the expected output?
The salary of an employee after being deducted

c. Write the pseudo code and construct the flow chart to solve the problem.

Pseudo code:
1. Start
2. Insert salary
3. Minus the salary with tax
4. Display the salary of an employee after being deducted
5. End
Flow chart:













Start
Salary - Tax
Salary after
deducted
End
Insert salary
3. Program 1 ( Relationship between the two integer)

a. Input, Process, Output







b. Pseudo code

1. Start
2. Insert first number
3. Insert second number
4. Determine whether the two numbers is equal, not equal, less, greater, less or equal,
greater or equal.
5. Relationship between the two number is stated
6. End

c. Flow chart











Input Process Output


2 number
a = = b
a != b
a < b
a > b
a <= b
a >= b


Relationship of integer
Start
Determine a
and b
relationship
Relationship
a and b
stated
End
Get a, b
d. Source code














e. Output






4. Program 2 ( greeting according time )

a. Input, Process, Output



b. Pseudo code

1. Start
2. Insert current time
3. Determine the time inserted with the range has been set
4. Display greeting
5. End

c. Flow chart











Input Process Output

Time
< 12.00p.m = selamat pagi
12.00p.m-7.00p.m = selamat petang
> 7.00p.m = selamat malam

Greeting
Start
Determine
the time with
range
Display
greeting
End
Get time
Time <
12.00
12.00
>=Time
<=1900
Time >
19.00
Yes
No
Yes Yes
No
Display
greeting
Display
greeting
d. Source code















e. Output





5. The different between ++c, c++, --c, and c--

Program A versus Program B
++c c++






When we use ++c in an equation,
Example:
Int c = 2, x;
x= 2 + ++c
the value of x is equal to 5
this is because the value of c is directly add by one

While,
When we use c++ in an equation,
Example:
Int c = 2, x;
x= 2 + c++
the value of x is equal to 4
this is because the value of c is not directly add by one. It will be added if there is a loop.


Program C versus Program D
--c c++








When we use --c in an equation,
Example:
Int c = 2, x;
x= 2 + --c
the value of x is equal to 3
this is because the value of c is directly subtract by one





While,
When we use c-- in an equation,
Example:
Int c = 2, x;
x= 2 + --c
the value of x is equal to 4
this is because the value of c is not directly subtract by one. It will be subtracted if there is a
loop.





DISCUSSION

1. Pseudo code and flow chart is not the same thing, the flow chart use a simple words and easy to
understand.
2. Typing an increment or decrement before and after an unknown can give different answer.
3. Use if in constructing a source code when the program contain a selection.
4. Using 24 hours format is easier when creating a time based program.

CONCLUSION
1. Pseudo code and flow chart is important to make easier for people to understand than
conventional programming language code.
2. Flow chart must be constructed with simplest words and easy to understand, it is different with
pseudo code which is usually it sentences is more detail.
3. Operators must be used wisely to avoid an error especially for increment and decrement.

Vous aimerez peut-être aussi