f5 chapter 5 programming question

53
5.1 Basic Programming Concepts 5.1.1 Define Program and Programming Language 5.1.1.1 State the definition of program . SECTION A 1. State True or False for the following statement. Nyatakan Benar atau Palsu pada pernyataan berikut. Programming is a series of organized instructions that directs a computer to perform task. Pengaturcaraan ialah satu siri arahan yang mengarahkan komputer untuk melaksanakan tugas. …………….. (SELANGOR 2010) 2. State whether the following statement is True or False. Nyatakan sama ada pernyataan berikut Benar atau Palsu. A program is a series of instructions that directs a computer to perform tasks. Program ialah satu siri arahan yang boleh dicapai terus oleh komputer untuk melaksanakan tugas. …………….. (TERENGGANU 2010) 5.1.1.2 State the definition of programming language. SECTION A 1. State whether the following statement is True or False. Nyatakan sama ada pernyataan berikut Benar atau Palsu. 1

Upload: bro-hafiz

Post on 05-Dec-2015

22 views

Category:

Documents


4 download

DESCRIPTION

ADGF

TRANSCRIPT

Page 1: f5 Chapter 5 Programming Question

5.1 Basic Programming Concepts

5.1.1 Define Program and Programming Language5.1.1.1 State the definition of program.

SECTION A

1. State True or False for the following statement.Nyatakan Benar atau Palsu pada pernyataan berikut.

Programming is a series of organized instructions that directs a computer to perform task.Pengaturcaraan ialah satu siri arahan yang mengarahkan komputer untuk melaksanakan tugas. ……………..

(SELANGOR 2010)2. State whether the following statement is True or False.

Nyatakan sama ada pernyataan berikut Benar atau Palsu.A program is a series of instructions that directs a computer to perform tasks.Program ialah satu siri arahan yang boleh dicapai terus oleh komputer untukmelaksanakan tugas. ……………..

(TERENGGANU 2010)

5.1.1.2 State the definition of programming language.

SECTION A

1. State whether the following statement is True or False.Nyatakan sama ada pernyataan berikut Benar atau Palsu.

A programming language is a set of rules that can be used to tell a computer what tasks to carry out.Bahasa pengaturcaraan adalah set aturan yang boleh digunakan untuk memberitahu komputer apa tugas untuk dilaksanakan. ……………..

(SPM 2008)

5.1.2 Levels and Generations Of Programming Languages5.1.2.1 Identify the generations of low-level programming languages with examples.

1

Page 2: f5 Chapter 5 Programming Question

SECTION A

1. Table 2 shows the criteria of two generations of low-level programming languages. Jadual 2 menunjukkan kriteria dua generasi bahasa pengaturcaraan aras rendah.

x. human-readable notation / nota yang boleh dibaca. use symbolic instruction codes / menggunakan kod arahan simbolik

Y. instructionsc an be executedd irectly by CPU / arahan boleh dilaksanakante rus oleh CPO. uses binary code / menggunakan kod binari

Table2 / Jadual 2

Based on Table2 , name the generation of programming language for:Berdasarkan Jadual 2 , namakan generasi bahasa pengaturcaraan untuk:(i) X =………………………………………….(ii) Y =………………………………………….

(SPM 2010)2. The lowest level of programming language is / Bahasa pengaturcaraan aras terendah ialah

A. BASIC / BASIC B. Natural language / Bahasa TabiiB. Machine language / Bahasa Mesin D. Assembly language / Bahasa Penghimpun

(KELANTAN 2010)3. State whether the following statement is True or False.

Nyatakan sama ada pernyataan berikut adalah Benar atau Palsu.i. Low-level programming language is a programming language that is more abstract, easier to use and

must translate into machine language before execution.i. Bahasa pengaturcaraan aras rendah adalah bahasa pengaturcaraan yang lebih abstrak, mudah

digunakan dan mesti diterjemahkan ke dalam bahasa mesin sebelum perlaksanaan.=………………………………………….

(PAHANG 2010)

4. Assembly language is the human-readable notation for the machine language used to control specific computer operations. This statement refers to high-level programming languages.Bahasa himpunan adalah bahasa mesin yang boleh difahami oleh manusia digunakanuntuk mengawal operasi komputer yang tertentu. Kenyataan ini merujuk kepada bahasapengaturcaraan paras tinggi. =………………………………………….

(TERENGGANU 2010)5. State whether the following statement is True or False. Nyatakan sama ada pernyataan berikut Benar atau Palsu. An assembly language programmer writes instructions using symbolic instruction codes. Pengaturcara bahasa penghimpun menulis arahan menggunakan kod arahan simbolik. =………………………………………….

(PUTRAJAYA 2010)

5.1.2.2 Identify the generations of high-level programming languages with examples.

SECTION A

1. State whether the following statement is True or False.Nyatakan sama ada pernyataan berikut Benar atau palsu.Program written using high level programming language must be translated into machines language before

2

Page 3: f5 Chapter 5 Programming Question

execution.Atur cara yang ditulis menggunakan bahasa pengaturcaraan aras tinggi mesti diterjemahkan ke dalam bahasa mesin sebelum dilaksanakan.=………………………………………….

(SPM 2009)2. State whether the following statement is True or False.

Nyatakan sama ada pernyataan berikut Benar atau PalsuFifth Generation programming language is more abstract and easier to use.Bahasa pengaturcaraan generasi ke-5 lebih abstrak dan lebih mudah digunakan.=………………………………………….

(TERENGGANU 2010)

5.1.3 Programming Language Approaches5.1.3.1 Define structured approach in programming.

SECTION A

1. Write the words that would complete the following statement: Tulis perkataan yang dapat melengkapkan pernyataan berikut: ………………………… approach is a computer programming technique in which the program is divided into modules. Pendekatan ………………………… adalah teknik pengaturcaraan komputer di mana aturcara dibahagi kepada beberapa modul.

(PUTRAJAYA 2010)2. State whether the following statements is True or False. Nyatakan sama ada pernyataan berikut Benar atau Palsu.

Structured programming usually uses top down design model. Pengaturcaraan berstruktur biasanya menggunakan model rekabentuk atas bawah. =…………………..

(PERLIS 2010)

5.1.3.2 Define object-oriented approach in programming.

SECTION A

1. Which is the following characteristics are related to an object-oriented programming approach.Yang mana merupakan ciri-ciri berkaitan dengan pendekatan pengaturcaraan berorientasikan objek.I. Main routine is broken into smaller sections.II. Data and instructions are seperatedIII. Data and instructions are encapsulated into a single unitIV. The programming language is event-driven

3

Page 4: f5 Chapter 5 Programming Question

I. rutin utama dipecah menjadi bahagian-bahagian yang lebih kecil.II. Data dan arahan dipisahkanIII. Data dan arahan diencapsulated ke dalam satu unitIV. Bahasa pengaturcaraan adalah event-driven

A. I and II B. I and IVC. II and III D. III and IV

(SPM 2008)2. Table 6 shows statements about programming approaches.

Jadual 6 menunjukkan pernyataan mengenai pendekatan pengaturcaraan.

XThis approach uses top-down design model. Complex problems are dividedinto a hierarchy of smaller and more manageable program modules.Pendekatan ini menggunakan model rekabentuk atas-bawah. Masalah yangkompleks dipecahkan kepada modul yang lebih kecil dan lebih terurus secaraberhirarki.YA programming approach that consists of objects that combines data and functionPendekatan pengaturcaraan yang terdiri daripada objek-objek yang menggabungkan data dan fungsi.

Table 6 / Jadual 6

Based on Table 6, name programming approach Berdasarkan Jadual 6, namakan pendekatan pengaturcaraan(i) X ……………………………………………(ii) Y ……………………………………………

(KEDAH 2010)

3. Figure 10 shows one example of programming approaches used by programmer to develop a program.Rajah 10 menunjukkan satu contoh pendekatan pengaturcaraan yang digunakan oleh pengaturcara untukmembangunkan satu program.

4

Page 5: f5 Chapter 5 Programming Question

Figure 10 / Rajah 10 Based on Figure 10, state whether the following statement is True or False.Berdasarkan Rajah 10, nyatakan sama ada pernyataan berikut Benar atau Palsu.(i) The whole program is broken down into modules.

Keseluruhan program dipecahkan menjadi modul- modul.(ii) ADA, Pascal and Visual Basic are examples of programming languages which used

these programming approaches.ADA, Pascal and Visual Basic merupakan contoh - contoh bahasa pengaturcaraanyang menggunakan pendekatan pengaturcaraan ini.…………………………

(N.SEMBILAN 2010)

5.1.3.3 Differentiate between structured approach and object-oriented approach in programming.

SECTION B

1. Figure 11 , shows types of programming approach.

5

Page 6: f5 Chapter 5 Programming Question

Rajah 11, menunjukkan jenis-jenis pendekatan pengaturcaraan.

Based on Figure 11, /Berdasarkan Rajah 11, / Namakan pendekatan pengaturcaraan bagi(a) Name the programming approach for :

(i) Figure 11 (i) ………………………………………………(ii) Figure 11 (ii) ………………………………………………

(b) State the differences of approach between the answer in (a)(i) and a(ii).Nyatakan perbezaan diantara jawapan dalam (a)(i) dan (a)(ii)………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………

(JOHOR 2010)

2. Figure 13(a) and 13(b) show flow charts of two programs.

Rajah 13(a) dan Rajah 13(b) menunjukkan carta alir bagi dua program.

6

START

READ X

END

X = X+ 20

PRINT X

Figure 13(a)

Rajah 13(a)

START

END

X > 20X = X + 20 X = X- 2

READ X

PRINT X

Figure 13(b)

Rajah 13(b)

Yes No

Page 7: f5 Chapter 5 Programming Question

Based on Figure 13(a) and Figure 13(b) / Berdasarkan Rajah13(a) dan Rajah 13(b),

(a)

Write the Output for the flowchart in figure 13(a) and 13(b) based on the Input Data in the Table 6.Tuliskan output untuk carta alir dalam Rajah 13(a) dan 13(b) berdasarkan data input di dalam Jadual 6.(i) 13(a) ………… (ii) 13(b) ………..

(b) What control structure is used in Figure 13(b). Give a reason.

Apakah struktur kawalan yang digunakan dalam Rajah 13(b).Berikan alasan.

………………………………………………………………………………………………(KELANTAN 2010)

5.1.4 Translator5.1.4.1 Describe the translation method of programming using assembler, interpreter and compiler.

SECTION A

1. Table 3 shows the characteristics of a pieqe of software, S, is used to run a program written in aprogramming larguage. Jadual 3 menuniukkan ciri-ciri sebuah perisian, S,.yang digunakan untuk melaksanakan sebuah program yang ditulis dalam bahasa pengaturcaraan.

. read statement and converts to object code / baca pernyataan dan tukar kepada kod objek

. execute line by line / melaksanakan baris demi baris7

Input Item Input DataX 12

YES NO

Table k

Table 6

Page 8: f5 Chapter 5 Programming Question

S is / S adalahA an assembler / penghimpun B a compiler / pengkompilasiC an interpreter / pentafsir D a translator / penterjemah

(SPM 2010)2. State whether the following statement is True or False.

Nyatakan sama ada pernyataan berikut Benar atau Palsu.

A translator is a form of hardware that translates a program into the language that the computer can understand.

Penterjemah ialah satu bentuk perkakasan yang menterjemahkan sebuah program ke dalam bahasa yang dapat difahami oleh komputer.=…………………..

(KELANTAN 2010)3. Table below shows the differences between Structured Programming and Object Oriented Programming.

Jadual di bawah menunjukkan perbezaan antara Pengaturcaraan Berorientasikan Objek dan

Pengaturcaraan Berstruktur

P Q

It often uses a top-down design model.Ia selalunya menggunakan model rekabentuk

atas bawah

It uses combinations of objects.

Ia menggunakan kombinasi objek

Examples - Ada, Pascal and Fortran.

Contoh - Ada, Pascal and Fortran.

Examples - Smalltalk, Java, Visual Basic and

C++.

Contoh - Smalltalk, Java, Visual Basic and C++.

Based on table above, name P and Q./Berdasarkan jadual di atas, namakan P dan Q.

P =…………………..

Q =…………………..

(MELAKA 2010)

4. Table 2 shows three methods of programming language translation.Jadual 2 menunjukkan tiga kaedah penterjemahan bahasa pengaturcaraan.

Translator / PenterjemahXDescription /PeneranganTranslate second generation programming language into machine language.Menterjemah bahasa pengaturcaraan generasi kedua kepada bahasa mesin.

Translator / PenterjemahYDescription /PeneranganExecutes instruction line by line until the end of the program.Menterjemah arahan baris demi baris sehingga akhir program.

8

Page 9: f5 Chapter 5 Programming Question

Translator / PenterjemahZ Description /PeneranganWhen the program running, the object code is loaded into the memory of the computer and the program instructions begin executing.Apabila program dilaksanakan, kod object akan dimuatkan ke dalam memori komputer dan suruhan -suruhan program mula dilaksanakan.

Table 2 / Jadual 2

Based on Table 2, state translator for :Berdasarkan Jadual 2, nyatakan penterjemah untuk :(i) X =…………………..(ii) Y =…………………..(iii) Z =…………………..

(N.SEMBILAN 2010)5. Write the word that would complete the following statement:

Tulis perkataan yang dapat melengkapkan pernyataan berikut:i) To convert an assembly language source code into machine language, programmer use a

program called a(n) …………………..Untuk menukarkan aturcara sumber bahasa himpunan ke bahasa mesin, pengaturcaraakan menggunakan satu program yang dipanggil …………………..

ii) A(n) ………………….. translates and executes one statement at a time.………………….. menterjemahkan dan melaksanakan satu arahan pada satu masa.

(PERLIS 2010)6. State whether the following statements is True or False.

Nyatakan sama ada pernyataan berikut Benar atau Palsu.An assembler translates and executes one statement at a time.Penghimpun menterjemah dan melaksanakan satu pernyataan pada satu masa.…………………..

(PERLIS 2010)

7. Figure 10 shows a process in program execution. Rajah 10 menunjukkan satu proses dalam pelaksanaan aturcara.

9

Figure 10

Rajah 10

Page 10: f5 Chapter 5 Programming Question

Based

on Figure

10, state

Process Y. / Berdasarkan Rajah 10, nyatakan Proses Y.

…………………..

(PUTRAJAYA 2010)

SECTION B

1. Figure 13 shows the process of two types of translator X and Y.Rajah 13 menunjukkan proses dua jenis penterjemah X dan Y.

Based on Figure 13 / Berdasarkan Rajah 13(a) Name translator / Namakan penterjemah

i. X …………………..ii. Y …………………..

(b) State a difference between translator X and translator YNatakan perbezaan antara penterjemah x dan penterjemah Y

…………………..…………………..…………………..…………………..…………………..…………………..

…………………..…………………..…………………..…………………..…………………..…………………..

…………………..…………………..…………………..…………………..…………………..…………………..

(SET PERCUBAAN PERAK 2010)

2. Figure 14 shows the type translators used in different level of Programming Language.Rajah 14 menunjukkan jenis-jenis enterjemah ang digunakan dalam bahasa pengaturcaraan yang berlainan

10

Source

Code

Process X

Process Y Object

Program

Program

Executed

Page 11: f5 Chapter 5 Programming Question

Based on Figure 14 : / Berdasarkan Rajah 14:,

(i) State Translator X , Y and the function of X / Nyatakan Penterjemah X , Y dan fungsi X.X = ……………………………… Y = ………………………………

Function X / Fungsi X = ……………………………………………………………………………………

……………………………………………………………………………………

(ii) Give one differences between Interpreter and Translator Y that are used for High Level Programming Language. Beri satu perbezaan Pentaksir dan Penterjemah Y yang digunakan untuk Bahasa Pengaturcaraan Aras Tinggi.

(SELANGOR 2010)5.1.5 Basic Elements In Programming5.1.5.1 Differentiate between constants and variables.

SECTION A

11

Page 12: f5 Chapter 5 Programming Question

1. Chooset he correct statementsr egardingv ariablesa nd constants. Pilih pernyataan yang betul tentang pemboleh ubah dan pemalar.I. Variables are identifiers / Pemboleh ubah adalah pengecamII. Constants are identifiers / Pemalar adalah pengecamIII.Variables are assigned values that may change / Pemboleh ubah digunakan untuk nilai yang boleh berubahIV. Constants are assigned values that may change / Pemalar digunakan untuk nilai yang boleh berubahA I, II and III. / I, II dan III B I, II and IV / I, II dan IVC I. III and IV / I, III dan IV D II, III and IV / U, ilI dan IV

(SPM 2009)2. Write the correct words to complete the following statement:

Tulis perkataan yang betul untuk melengkapkan pernyataan berikut:

During the execution of a program the value of a (i) . can be changed whereas the value of a (ii) . cannot be changed.Semasa aturcara dilaksanakan nilai sesuatu ( i ) ……………………. boleh diubah sedangkan nilai untuk (ii) …………………….tidak boleh diubah.

(SPM 2010) 3. Figure 9 shows an incomplete program./ Rajah9 menunjukkan at urcara yang tidak lengkap.

Dim Name as XDim PI as YName = "Ali"PI = 3.142

Figure 9 / Rajah 9Based on Figure 9 , identify; / Berdasarkan Rajah 9 , kenalpasti:Y= …………………….

(SPM 2010)

4. Read the following situation : /Baca situasi berikut:

This program will calculate the price of an item after 5% discount. The user keys in the price ofthe item and the program will calculate and display the price after discount.Aturcara ini akan mengira harga barang selepas diberi diskaun sebanyak 5%. Pengguna akanmemasukkan harga barang dan aturcara akan mengira dan memaparkan harga selepas diberidiskaun

Based on the situation, name the constant used.Berdasarkan kepada situasi, nyatakan pemalar yang digunakan.…………………….

(JOHOR 2010)

5. Figure 6 shows an algorithm to calculate the total of x and y.Rajah 6 menunjukkan algoritma untuk mengira jumlah x dan y.

12

Page 13: f5 Chapter 5 Programming Question

Figure 6 / Rajah 6Name one variable. / Namakan satu pembolehubah.…………………….

(JOHOR 2010)6. Figure 7 shows part of programming code Total Parking Charges. Rajah 7 menunjukkan sebahagian daripada kod atur cara Total Parking Charges.

Based on 7 figure, state one : / Berdasarkan rajah 7, nyatakan satu :Variable :/ Pembolehubah: …………………….

(KELANTAN 2010)

7. Figure 8 shows a portion of a programming code. Rajah 8 menunjukkan sebahagian kod pengaturcaraan.

13

Private Sub calculate_Click()Dim Hour, Minute As IntegerDim Total As Single

msg = "Total Parking Charges is "TimeEntry = ((Total1 * 60) + Total2) / 60

lblCharges.Caption = TimeEntryIf TimeEntry <= 0.5 Then

lblCharges.Caption = msg & "RM0.20"ElseIf TimeEntry > 0.5 AND TimeEntry <= 1 Then

lblCharges.Caption = msg & "RM0.50"ElseIf TimeEntry > 1 AND TimeEntry <= 1.5 Then

lblCharges.Caption = msg & "RM1.50"ElseIf TimeEntry > 1.5 Then

jb = 0.7 + (TimeEntry * 0.8)lblCharges.Caption = msg & "RM" & jb

End IfEnd Sub

Figure 7

Page 14: f5 Chapter 5 Programming Question

Figure 8 / Rajah 8 State one / Nyatakan satu (a) Constant / Pemalar ……………………. (b) Variable / Pemboleh ubah …………………….

(SET PERCUBAAN PERAK 2010)

8. Figure 8 shows the flow chart for a program that calculate the area of circle. Rajah 8 menunjukkan carta alir program penghitungan luas bulatan.

Based on Figure 8: / Berdasarkan rajah 8:Which element in the program can be define as a constant?Elemen yang manakah pada program merupakan pemalar ?…………………….

(SELANGOR 2010)SECTION B

1. Figure 12(a) shows the input interface and Figure 12 (b) shows the output interface of a program.Gambar 12 (a) menunjukkan antara muka input dan Gambar 12 (b) menunjukkan antara muka output dari

14

Page 15: f5 Chapter 5 Programming Question

sebuah program..

Based on Figure l2(a) and Figure I2(b), / Berdasarkan Rajah 12(a) dan Rajah I2(b),(i) Should the Numerator declared as a constant?

Patutkah Numerator itu diisytiharkan sebagai pemalar?…………………….

(ii) Give a reason for your answer./Beri satu alasan bagi jawapan anda.…………………….…………………….…………………….…………………….…………………….…………………….…………………….…………………….…………………….…………………….

(SPM 2009)

SECTION C

1. Table 5 shows a problem statement which is to be written in Visual Basic 6.0.Jadual 5 menunjukkan satu pernyataan masalah yang akan ditulis dalam Visual Basic 6.0.

This program calculates the volume of water to be filled in a cuboid aquarium. Given that the length and

15

Page 16: f5 Chapter 5 Programming Question

width of the aquarium is 150 cm and 50 cm respectively. The user will key in the height or level of waterto be filled in the aquarium. Maximum level of water is 70 cm. The program will calculate and display thevolume of water needed based on the water level entered by user.Aturcara ini mengira isipadu air yang perlu diisi ke dalam akuarium berbentuk kuboid. Diberi panjangdan lebar akuarium ialah 150 cm dan 45 cm. Pengguna perlu memasukkan ketinggian atau aras air untukdiisi ke dalam akuarium. Aras air maksimum ialah 70 cm. Aturcara ini akan mengira dan memaparkanisipadu air yang diperlukan berdasarkan ketinggian air yang dimasukkan oleh pengguna..

Table 5 / Jadual 5a) State the constant and variable to be used. Give the reasons to your answers.

Nyatakan pemalar dan pembolehubah yang digunakan. Berikan alasan kepada jawapan anda.…………………….…………………….…………………….…………………….…………………….…………………….…………………….…………………….…………………….…………………….…………………….…………………….

b) Draw user interface for input and output of the program. Lakar antaramuka input dan output bagi aturcara ini.

(PERLIS 2010)5.1.5.2 Differentiate between the data types: Boolean,integer, double, string and date.

SECTION A

1. Table 3 shows some types of data. / Jadual 3 menunjukkan beberapa jenis data.

16

Page 17: f5 Chapter 5 Programming Question

Table.3 / Jadual 3

Based on Table 3, state the types of data for:/ Berdasarkan Jadual 3, nyatakan jenis data untuk:(i) R …………………….(ii) S …………………….

(SPM 2009)2. Figure 9 shows an incomplete program. / Rajah9 menunjukkan at urcara yang tidak lengkap.

Dim Name as XDim PI as YName = "Ali"PI = 3.142

Figure 9 / Rajah 9Based on Figure 9 , identify; / Berdasarkan Rajah 9 , kenalpasti:X= …………………….

(SPM 2010)

3. Choose the correct examples regarding data types. Pilih contoh yang betul tentang jenis data.

A I and II B I and IIIC II and IV D III and IV

(PAHANG 2010)

4. The following statement explains the operation of a taxi company.Pernyataan berikut menerangkan tentang operasi sebuah syarikat teksi.

17

Page 18: f5 Chapter 5 Programming Question

Based on the

above

statements:/ Berdasarkan pernyataan di atas:State three data types for the three data items required for the coupon system.Nyatakan tiga jenis data untuk tiga item data yang diperlukan untuk sistem kupon itu.……………………. , ……………………. & …………………….

(SET PERCUBAAN PERAK 2010)5. Table 4 shows the pseudo code for a program. / Jadual 4 menunjukkan kod pseudo untuk satu aturcara.

Table 4 / Jadual 4Based on Table 4,/ Berdasarkan Jadual 4,State the data type for ‘ID’Nyatakan jenis data untuk ‘ID’ …………………….

(PUTRAJAYA 2010)

SECTION B

1. Figure 12(a) shows the input interface and Figure 12 (b) shows the output interface of a program.

18

BeginRequest IDIf ID is equal to AB74G3 then Print “You are allow to access the database”Else Print “Sorry, your ID is not correct”End ifEnd

Page 19: f5 Chapter 5 Programming Question

Gambar 12 (a) menunjukkan antara muka input dan Gambar 12 (b) menunjukkan antara muka output dari sebuah program..

Based on Figure l2(a) and Figure I2(b), / Berdasarkan Rajah 12(a) dan Rajah I2(b),(i) State the data type that should be used for both interface.

Nyatakan jenis data yang patut digunakan untuk kedua-dua antara muka.…………………….

(ii) Give a reason for your answer. / Beri satu alasan bagi jawapan anda.…………………….…………………….…………………….…………………….…………………….

(SPM 2009)2. Figure 15 shows a user interface of a program used in Holborn Restaurant to calculate the yearly bonus for

their employees. The employees who have been working for at least three years will be given a bonus of RM1 000. Rajah I5 menunjukkan satu antara muka pengguna bagi satu atur cara yang digunakan oleh Restoran Holborn untuk mengira bonus tahunan bagi pekerjanya. Pekerja yang sudah bekerja sekurang-kurangnya tiga tahun akan diberikan bonus RM1000.

Figure 15 / Rajah 15Based on Figure 15: / Berdasarkan Rajah I5:State an appropriate data type for the variable 'Identity Card No. State one reason for yo'ur answer.Nyatakan satu jenis data yang sesuai bagi pemboleh ubah 'Identity Card No.Beri satu alasan anda.…………………….…………………….…………………….…………………….…………………….…………………….…………………….…………………….…………………….…………………….…………………….

(SPM 2010)SECTION C

1. As an ICT student, Abu is asked to develop a program to calculate the price of bus ticket forseveral destinations in a special promotion during the school holidays. Here is the algorithm:

19

Page 20: f5 Chapter 5 Programming Question

Sebagai pelajar ICT, Abu diminta membangunkan aturcara yang dapat mengira harga tiket bassempena promosi istimewa untuk pelbagai destinasi sepanjang cuti sekolah. Algorithmaaturcata tersebut adalah seperti berikut:

BeginRead DestinationRead Ticket priceRead number of adultRead number of childrenIf passenger buy more than three tickets or amembership card holderGive 10% discountCalculate a ticket price for adultCalculate a ticket price for childrenCalculate the amount of the ticketsCalculate and display the total price after discountElseNo discount givenCalculate the ticket price for adultCalculate the ticket price for childrenCalculate the amount of the ticketsCalculate and display the total price without discountEnd

Figure 12 / Rajah 12

(a) Determine two data types used in the program.Tentukan dua jenis data yang digunakan di dalam aturcara..

I. …………………….II. …………………….

(JOHOR 2010)

5.1.5.3 Differentiate between mathematical and logical (Boolean) operators.

SECTION A

1. Figure 10 shows types of operator. / Rajah I0 menunjukkanje nis-jeniso perator.

20

Page 21: f5 Chapter 5 Programming Question

Figure 10 / Rajah 10Based on Figure 10, state two logical operators.Berdasarkan Rajah 10, nyatakan dua operator logik.…………………….……………………. & …………………….…………………….

(SPM 2009)2. Table below shows examples of operator symbols that being used in programming.

Jadual di bawah menunjukkan contoh simbol-simbol operator yang digunakan dalam

pengaturcaraan.

S ‘ OR ‘ ‘ AND’

T ‘ * ‘ ‘ + ‘

U ‘ < ‘ ‘ > ‘

Based on table above, write S, T or U for the following operator types.

Berdasarkan jadual di atas, tuliskan S, T atau U bagi jenis-jenis operator berikut:

i. Logical Operator / Operator Logik …………………….

ii. Mathematical Operator / Operator Matematik …………………….

(MELAKA 2010)

3. Table 4 shows some types of operator element in programming.Jadual 4 menunjukkan beberepa jenis elemen operator dalam pengaturcaraan.

Table 4 / Jadual 4Based on Table 4, state the types of operator for:/ Berdasarkan Jadual 4, nyatakan jenis operator bagi:(i) R …………………….(ii) S …………………….

(PAHANG 2010)4. Figure 7 shows part of programming code Total Parking Charges. Rajah 7 menunjukkan sebahagian daripada kod atur cara Total Parking Charges.

21

Private Sub calculate_Click()Dim Hour, Minute As IntegerDim Total As Singlemsg = "Total Parking Charges is "TimeEntry = ((Total1 * 60) + Total2) / 60

lblCharges.Caption = TimeEntryIf TimeEntry <= 0.5 Then

lblCharges.Caption = msg & "RM0.20"ElseIf TimeEntry > 0.5 AND TimeEntry <= 1 Then

lblCharges.Caption = msg & "RM0.50"ElseIf TimeEntry > 1 AND TimeEntry <= 1.5 Then

lblCharges.Caption = msg & "RM1.50"ElseIf TimeEntry > 1.5 Then

jb = 0.7 + (TimeEntry * 0.8)lblCharges.Caption = msg & "RM" & jb

End IfEnd Sub

Page 22: f5 Chapter 5 Programming Question

Based on 7 figure, state one : / Berdasarkan rajah 7, nyatakan satu :Logical Operator: / Operator Logik: …………………….

(KELANTAN 2010)

5. State whether the following statements is TRUE or FALSENyatakan sama ada kenyataan berikut adalah TRUE atau FALSE

a. Boolean data types consists either a True or False value. Programmers usually use it to store status. jenis data Boolean terdiri daripada sama ada nilai Benar atau Salah. Programer biasanya menggunakannya untuk menyimpan status…………………….

b. Logical operators are notations that tell the computer to perform logical operations. Examples of logical operation are Plus, Minus, Multiply and DivideOperator Logik memberitahu komputer untuk melakukan operasi logik. Contoh operasi logik Tambah, Tolak, Darab dan Bahagi…………………….

(SET PERCUBAAN SABAH 2010)

6. Figure 7 shows types of operator. / Rajah 7 menunjukkan jenis-jejis operator

22

Figure 7 /Rajah 7

OR

>=

+ -

NOT

Page 23: f5 Chapter 5 Programming Question

Figure 7 / Rajah 7

Based on figures 7, state two logical operators / Berdasarkan Rajah 7 , nyatakan dua operator logik.……………………. & …………………….

(SELANGOR 2010)

7. Figure 11 shows the operator used in programming.Rajah 11 menunjukkan operator yang digunakan di dalam aturcara.

Figure 11 / Rajah 11Based on Figure 11, state the operator used.

Berdasarkan Rajah 11, nyatakan operator yang digunakan.

…………………….(PUTRAJAYA 2010)

SECTION C

1. As an ICT student, Abu is asked to develop a program to calculate the price of bus ticket forseveral destinations in a special promotion during the school holidays. Here is the algorithm:Sebagai pelajar ICT, Abu diminta membangunkan aturcara yang dapat mengira harga tiket bassempena promosi istimewa untuk pelbagai destinasi sepanjang cuti sekolah. Algorithmaaturcata tersebut adalah seperti berikut:

BeginRead DestinationRead Ticket priceRead number of adultRead number of childrenIf passenger buy more than three tickets or amembership card holderGive 10% discountCalculate a ticket price for adult

23

Page 24: f5 Chapter 5 Programming Question

Calculate a ticket price for childrenCalculate the amount of the ticketsCalculate and display the total price after discountElseNo discount givenCalculate the ticket price for adultCalculate the ticket price for childrenCalculate the amount of the ticketsCalculate and display the total price without discountEnd

Figure 12 / Rajah 12

(i) State two types of operators used in the program above.Nyatakan dua jenis operator yang digunakan dalam aturcara di atas…………………….& …………………….

(ii) Explain the differences between operators in answer (b)(i).Terangkan perbezaan di antara operator dalam . jawapan (b)(i).…………………….…………………….…………………….…………………….…………………….…………………….…………………….…………………….…………………….…………………….…………………….…………………….…………………….…………………….…………………….…………………….…………………….…………………….…………………….…………………….

(JOHOR 2010)

5.1.5.4 Differentiate between sequence control structure and selection control structure.

SECTION A

1. Figure 8(a) and 8(b) show flowchart segments / Rajah 8 (a) dan 8(b) menunjukkan segmen carta alir

Figure 8(a) Figure 8(b)

24

Page 25: f5 Chapter 5 Programming Question

Identify the control structure used in / kenalpasti struktur kawalan yang digunakan pada;i) Figure 8(a) …………………………………………………….ii) Figure 8(b) …………………………………………………….

(SPM 2007)2. A programmer uses flowcharts to code a program Pengaturcara menggunakan carta alir untuk mengekod aturcara

TRUE / FALSE(SPM 2007)

3. Which of the following symbols represents a decision in a selection control structure? Antara yang berikut simbol yang manakah mewakili keputusan dalam struktur kawalan pilihan?

(SPM 2009)

4. Figure 10(a) and 10(b) shows partial flowcharts of two programs.Rajah 10(a) dan IA(b) menunjukkan sebahagian carta alir untuk dua program.

25

Page 26: f5 Chapter 5 Programming Question

Figurel0(a) / Rajah 10(a)

Identify the control structure used in: / Kenal pasti struktur kawalan yang digunakan dalam:(i) Figure 10(a) / Rajah 10(a) ……………………………………………………………………………..(ii) Figure 10(b) / Rajah 10(b) ……………………………………………………………………………..

(SPM 2010)5. Which type of control structure is represented by the following pseudo code?

Struktur kawalan manakah yang diwakili oleh kod pseudo di bawah?

A. Decision Control Structure / Struktur Kawalan Keputusan

B. Repetition Control Structure / Struktur Kawalan PengulanganC. Sequence Control Structure / Struktur Kawalan JujukanD. Selection Control Structure / Struktur Kawalan Pilihan

(N.SEMBILAN 2010)6. Figure 11 shows one symbol of flow chart. / Rajah 11 menunjukkan satu simbol dalam carta alir.

Figure 11 / Rajah 11Name Y. / Namakan Y.……………………………

(N.SEMBILAN 2010)7. Table 4 shows types of control structure. Jadual 4 menunjukkan jenis struktur kawalan.

A Selection control structure struktur kawalan pilihanB Repetition control structure struktur kawalan PengulanganC Sequence control structure struktur kawalan jujukanD Consecutive control structure struktur kawalan turutan

Table 4 / Jadual 4Match A, B, C, and D in Table 4 with the following statements: Padankan A, B, C, dan D dalam Jadual 4 dengan kenyataan berikut:

i. Enables the programmer to assign different events for different situations. Programmers can use it to implement decision making process. Membolehkan programmer untuk menetapkan acara yang berbeza untuk situasi yang berbeza. Pengaturcara boleh menggunakannya untuk melaksanakan proses pengambilan keputusan =………

26

Page 27: f5 Chapter 5 Programming Question

ii. Executes statements one by one in linear or consecutive order Melaksanakan satu demi satu dalam urutan linear atau berturut-turut =………

(SET PERCUBAAN SABAH 2010)8. Table 4 shows the pseudo code for a program. / Jadual 4 menunjukkan kod pseudo untuk satu aturcara.

Table 4 / Jadual 4Based on Table 4,/ Berdasarkan Jadual 4,State the type of control structure is used in the pseudo code.Nyatakan jenis struktur kawalan yang digunakan di dalam kod pseudo.……………………………………………

(PUTRAJAYA 2010)

(SELANGOR 2010)9. Figure 9 shows the flow chart of a Progamme / Rajah 9 menunjukkan carta alir bagi satu Program

Figure 9 / Rajah 9

Based on figure 9, / Berdasarkan rajah 9,Name the control stuctured used the programme.Namakan jenis struktur kawalan yang digunakan dalam program.………………………………………………………………….

27

BeginRequest IDIf ID is equal to AB74G3 then Print “You are allow to access the database”Else Print “Sorry, your ID is not correct”End ifEnd

Page 28: f5 Chapter 5 Programming Question

10. Figure 7 shows a pseudo code. / Rajah 7 menunjukkan satu kod pseudo.

Figure 7 / Rajah 7Which of the following flow chart represents the pseudo code in Figure 7.Yang manakah antara carta alir berikut menggambarkan kod pseudo dalam Rajah 7.

(PAHANG 2010)28

Page 29: f5 Chapter 5 Programming Question

SECTION B

1. Figure 15 shows a user interface of a program used in Holborn Restaurant to calculate the yearly bonus for their employees. The employees who have been working for at least three years will be given a bonus of RM1 000. Rajah I5 menunjukkan satu antara muka pengguna bagi satu atur cara yang digunakan oleh Restoran Holborn untuk mengira bonus tahunan bagi pekerjanya. Pekerja yang sudah bekerja sekurang-kurangnya tiga tahun akan diberikan bonus RM1000.

Figure 15 / Rajah 15

Based on Figure 15: / Berdasarkan Rajah I5:State an appropriate data type for the

variable 'Identity Card No.'.Identify the control structure used in the program.Kenal pasti struktur kawalanyang digunakan dalam atur cira ini.Justify your answer.Berikan justifikasi anda.…………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………

(SPM 2010)2. Figure 12 below shows one of the phases in program development

Gambar 12 di bawah ini menunjukkan salah satu fasa dalam pembangunan program

29

Print “X is greater than Y”

Read

X, Y

Start

End

Print “X is less than or equal to Y”X > Y

TRUE

FALSE

Page 30: f5 Chapter 5 Programming Question

Figure 12

Based on the flow chart above, answer the following questions: Berdasarkan diagram alir di atas,jawab soalan-soalan berikut:

a. There are mistakes in the flow chart above. Identify them by re-drawing with the correct symbol.Terdapat kesalahan dalam carta alir di atas. Kenalpastinya dengan melukis kembali dengan menggunakan simbol yang benar.

b. (i) Name the phase that involve the flow chart above.Namakan fasa yang melibatkan diagram alir di atas……………………………………………………

(ii) What is the output if X = 6 and Y = 9?Apa output jika X = 6 dan Y = 9?……………………………………………………

(SET PERCUBAAN SABAH 2010)SECTION C

1. Table 8 shows statement about a programming project.Jadual 8 menunjukkan pernyataan tentang satu projek pengaturcaraan.

Alia is a form 5 Cyber student who is taking ICT subject. She is required to write a program to calculate the area of a circle by using the formula, area of circle =πr2 . The program should allow the user to key‐in the radius of the circle. Use a formula to calculate and display the area of the circle.Alia adalah pelajar tingkatan 5 Cyber yang mengambil mata pelajaran ICT. Dia dikehendakki menulis aturcara untuk mengira luas bulatan dengan menggunakan formula, Luas bulatan = πr2 . Aturcara tersebut memintapengguna memasukkan nilai jejari bulatan. Gunakan formula untuk mengiradan paparkan hasilnya.

Table 8 / Jadual 8

(i) What are the input, process and output of the program?Apakah input, proses dan output bagi aturcara ini?……………… , ……………… & ………………

(ii) Draw a flowchart for the program.Lukis carta alir bagi program tersebut.

(KEDAH 2010)

30

Page 31: f5 Chapter 5 Programming Question

2. Figure 18 shows development of a programme. Rajah 18 menunjukkan pembangunan satu program

Figure 18 / rajah 18Based on the case study and pseudo code at figure 18: Berdasarkan kajian kes dan kod pseudo pada rajah 18:a. Identify the input, process and output of the program / Kenalpasti input, proses dan output program .

Input =…………………………………………………………Output =…………………………………………………………Process =…………………………………………………………

b. Based on the Pseudo code given, draw a suitable flow chart to show the flow of program. Berdasarkan kod pseudo yang diberi, lakarkan carta alir yang sesuai program berkenaan.

31

Case StudyYour school needs a registration program to computerize the registration of Curriculum Unit. Any student in the school should have all his/her data like name, class and IC number keyed into the Curriculum Unit registration program. After the program verifies the student data and all fields are filled, they will notified of his/her Curriculum Unit for the coming academic year.

Pseudo CodeBEGINKey in students’ data (verify data)

If all fields filled thenPrint curriculum unit

ElsePrint error message

End ifEND

Page 32: f5 Chapter 5 Programming Question

(SELANGOR 2010)

5.2 Program Development5.2.1 Program Development Phases5.2.1.1 Describe the five main phases in program development:• problem analysis • program design • coding • testing and debugging • documentation

SECTION A

1. Figure 9 show program development phase / Rajah 9 menunjukkan fasa pembangunan aturcara

Phase 2 and Phase 4 for the proper program development phase are :Fasa 2 dan 4 adalah;i) Phase 2 =………………………………………………….ii) Phase 4 =………………………………………………….

(SPM 2007)2. State the first phase and third phase of program development

Nyatakan fasa pertama dan ketiga dalam pembangunan aturcaraI. First phase =……………………………II. Third phase =……………………………

(SPM 2008)3. Complete the following statements by filling in the blanks:

Isikan ruang kosong untuk melengkapkan pernyataan berikut:The process of detecting, locating and correcting logic errors is called ……………………………

Proses mengesan, mencari dan memperbaiki kesalahan logik disebut ……………………………(KELANTAN 2010)

32

1 Problem analysis

2

3 Coding

4

5 Documentation

Page 33: f5 Chapter 5 Programming Question

4. Figure 13 (a) is the source code while 13(b) is the flow chart for the ICT Result program.Rajah 13 (a) adalah kod sumber manakala 13 (b) merupakan carta alir bagi program markah ICT

Figure13(a)

Figure 13 (b)Based

on Figure 13(a) and 13(b), answer the following questions:Berdasarkan rajah 13 (a) dan 13 (b), jawab soalan-soalan berikut;

i. States which phase comes after the process in Figure 13(a).

33

Private Sub CommandCheck_Click()Dim marks As Double, response As Stringmarks = TextMark.TextIf (marks >= 50) Then

response = MsgBox(“You have pass your ICT examination”, vbOKOnly, “Pass”)Else

response = MsgBox(“You have fail your ICT examination”, vbOKOnly, “Fail”)End IfEnd Sub

Begin

>= 50?

Request marks

Print “You have fail your ICT examination.”

End

Print “You have pass your ICT examination.”

No

Yes

Page 34: f5 Chapter 5 Programming Question

Nyatakan fasa yang terlibat selepas proses dalam rajah 13(a)……………………………

ii. Design the output interface for both of the outcomes.Rekabentuk output antaramuka bagi kedua-dua hasil

(SET PERCUBAAN SABAH 2010)5. Table 2 shows the five main phases in program development.

Jadual menunjukkan lima fasa utama dalam pembangunan aturcara.

Table 2 / Jadual 2Match the phases with the following statement by writing A, B, C, D or E.Padankan fasa tersebut dengan penyataan berikut dengan menulis A, B, C, D atau E.

i) Programmers identify the data input, process and output of the program.Pengaturcara mengenalpasti data input, proses dan output bagi sesuatu program.……………..

ii) Programmer ensure the program runs correctly and is error free.Pengaturcara memastikan program dijalankan dengan lancar dan tiada kesalahan.……………..

iii) The process of writing solution using a computer programming language.Proses menyelesaikan masalah menggunakan bahasa pengaturcaraan komputer.……………..

(TERENGGANU 2010)

34

Page 35: f5 Chapter 5 Programming Question

6. Table 5 shows the activities involved in the phases in program development.Jadual 5 menunjukkan aktiviti-aktiviti yang terlibat di dalam fasa pembangunan aturcara.

XTranslate pseudo code or flowcharts in programming language Menterjemah kod pseudo atau carta alir kepada bahasa pengaturcaraan

Y Identify input, output and processing requirementsMengenalpasti keperluan input, output dan pemprosesan.

Table 5 / Jadual 5Based on Table 5, identify phase; / Berdasarkan Jadual 5, kenalpasti fasa;(i) X ……………..……………..(ii) Y ……………..……………..

(PUTRAJAYA 2010)

5.2.2 Develop a program5.2.2.1 Apply program development phases to solve problems.

35

Page 36: f5 Chapter 5 Programming Question

SECTION A

1. Table 2 shows tasks carried out during a program development cycle.Jadual 2 menunjukkan tugas dilakukan selama kitaran program pembangunan.

P Write program / Menulis programQ Draw user interface / lukis antara muka penggunaR Indentify input and output / mengenalpasti input dan outputS Produce the user guide / Menghasilkan buku manualT Check for errors / Semak kesalahan

Based on Table 2, select P, Q, R, S and T for the following phases of the program development cycle :i. Problem analysis ……………..ii. Documentation ……………..

(SPM 2008)2. Which of the following are done during the documentation phase in program development phase?

A. Johan interviews his client to find out the client needs.B. Johan writes a report that consists of all the descriptions of the program, source code and

maintenances.C. Johan test the program for any error.D. Johan corrects the program source code

Manakah daripada yang berikut ini dilakukan semasa fasa dokumentasi dalam tahap program pembangunan? A. Johan wawancara kliennya untuk mengetahui keperluan pelanggan.B. Johan menulis sebuah laporan yang terdiri daripada semua keterangan daripada kod, program sumber dan penyelenggaraan.C. Johan menguji program untuk kesalahan apapun.D. Johan membetulkan kod sumber program

(SET PERCUBAAN SABAH 2010)SECTION B

1. Figure 1 shows the phases in program development.Rajah 1 menunjukkan fasa pembangunan aturcara.

a. Name phase X and phase Y. Namakan fasa X dan fasa Y.X = ……………..Y = ……………..

b. State one tool that is used during phase X.Nyatakan satu alat yang digunakan semasa fasa X.……………..……………..……………..……………..

c.

36

Page 37: f5 Chapter 5 Programming Question

Give the importance of the statement Z in the source code above. (1 Mark )Berikan satu kepentingan Pernyataan Z dalam kod sumber di atas.……………………………………………………………………………………………….……………………………………………………………………………………………….……………………………………………………………………………………………….

(PERLIS 2010)SECTION C

1. Table 4 shows text and grading range for all subjects in Sekolah Menengah Kebangsaan Pelita.Jadual 4 menunjukkan teks dan julat gred bagi semua mata pelajaran di SMK Pelita.

Based on the text: / Berdasarkan teks itu:

(a) State four activities which will be performed by Ahmad in program analysis.Nyatakan empat aktiviti yang akan dilakukan oleh Ahmad dalam menganalisis program.…………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………

37

Page 38: f5 Chapter 5 Programming Question

(b) Ravi tested the system and entered the mark 69 and,the output is grade D.Ravi menguji sistem dengan memasukkan markah 69 dan outputnya menunjukkan gred D.(i) What type of error is this? / Apakah jenis ralat ini?

………………………………………………………………………………………………… (ii) Justify your answer. / Berikan justifikasi anda.

………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………

(SPM 2010)

2. You are asked to develop a program to calculate the area of a circle. The program should allow the user to key in the input and display the output.Anda dikehendaki membangunkan sebuah atur cara untuk mengira keluasan sebuah bulatan. Atur cara tersebut membenarkan pengguna memasukkan data dan memaparkan keputusan pengiraan.(a) Draw a flowchart for the program. / Lukis carta alir bagi aturcara tersebut.

(b) i) State a constant and a variable to be used.Nyatakan pemalar dan pembolehubah yang akan digunakan.…………………………………………………………

ii) Write down the fomula of the calculation.Tuliskan formula bagi pengiraan keluasan bulatan

(N.SEMBILAN 2010)

5.3 Current and Future Developments

5.3.1 Latest Programming Languages5.3.1.1 Find out the latest programming languages:• fifth generation language • natural language• OpenGL (Graphic Library)

38