You are on page 1of 28
SULIT a POUT SHnil< MALAYSIA BAHAGIAN PEPERIKSAAN DAN PENILAIAN JABATAN PENDIDIKAN POLITEKNIK, KEMENTERIAN PENDIDIKAN MALAYSIA f JABATAN TEKNOLOGI MAKLUMAT DAN KOMUNIKASI PEPERIKSAAN AKHIR SESI DISEMBER 2015 DFC2013: PROGRAMMING FUNDAMENTALS TARIKH ; 07 APRIL 2016 (KHAMIS) MASA + 11,15 AM—-1.15 PM (2 JAM) Kertas ini mengandungi DUA PULUH ENAM (26) halaman bercetak. Bahagian A: Objektif (30 soalan) Bahagian B: Struktur (2 soalan) Dokumen sokongan yang disertakan : Tiada JANGAN BUKA KERTAS SOALAN INI SEHINGGA DIARAHKAN (CLO yang tertera hanya sebagai rujukan) SULIT SULIT DFC2013: PROGRAMMING FUNDAMENTALS CLOL cL CLOL cl SECTION A: 4SMARKS BAHAGIAN A: 45MARKAH ———<—<—$ —————————_________f INSTRUCTION: This section consists of THIRTY (30) objective questions. Mark your answers in the OMR_ form provided. ARAHAN: Bahagian ini mengandungi TIGA PULUH (30) soalan objektif. Tandakan jawapan anda di dalam borang OMR yang disediakan. 1, [Error that ocours while program is running; when the program attempts an operation that is impossible to carry out, Ralat yang berlaku semasa program berjalan; apabila program cuba melaksanakan satu operasi yang mustahil untuk dijalankan, Figure Al/Rajah Al Select the CORRECT answer based on the statement in Figure Al. Pilih Jawapan yang BETUL berdasarkan pernyataan dalam Rajah Al A. Compile Error Ralat Susunan B. Logie Error Ralat Logik C. Syntax Error Ralat Sintaks D._ Run-Time Error Ralat Masa Laksana 2, Identify the symbol that must end the C++ code statement. Kenalpasti symbol yang mesti diakhiri pada setiap kod pernyataan C++ comma semicolon colon hash pop 2 SULIT SULIT DFC2013: PROGRAMMING FUNDAMENTALS. CLO1 /3. Identify the operator that compares between two variables. cL Kenalpasti operator bagi membandingkan dua pembolehubah A B. c, D, CLOI | 4. Select the identifier based on the following answer. C2 Pilih pencam berdasarkan jawapan bertkut A. Sum_2 B. Sum2 Cc. SU_M2 D. 2SUM CLOL |5. Choose the suitable header file for mathematical function of sqrt(). c2 Pilth kepala fail yang sesuai digunakan untuk. fungsi matematik sqrt(). A. stdlibh B. string. h CC. iomanip.h D. math CLOI }6. Choose the syntax to declare a variable named totalPtr of type double. 3 Pilih sintaks bagi mengisytiharkan pembolehubah totalPtr jenis double. A. double totalPtr; B. double *totalPtr; C. Double totalPir; D. double totPtr = CLO1 |7. _ Identify which is NOT the type of looping control structure, cl Kenalpasti yang manakah BUKAN jenis siruktur kawalan gelung, A. for B. while C. if...else D. do...while suLir CLOL c CLOL c2 cLo2 cl Determine the numbers of ‘do... while” loop which are guaranteed to loop. Tentukan bilangan kali ‘do...while’ dijamin untuk membuat ulangan. A. 0 Bo G22 D. Infinitely If sum is greater or equal to 40 and the average is equal to 25 Figure A2/Rajah A2 ‘The sentence in Figure A2 is the condition statement in a selection control structure. Identify the CORRECT statement to write the condition statement in C++ Ayat dalam Rajah A2 merupakan pernyataan syarat di dalam struktur kawalan pilihan, Kenalpasti pernyataan yang BETUL untuk menulis pernyataan syarat di dalam CH. A. if (sum >=40) || (average B. if (Gum >=40) && (average C._ if (sum > 40) && (average = 25) D. if (sum = 40) || (average = 25) Choose the syntax for an ‘if’ statement. Pilih sintaks untuk satu pernyataan ‘if’ if expression if { expression } if ( expression ) expression if par> 4 suLIT cl #include int main()( for(int h =0; ; } cout<<"Hi Figure A3/Rajah A3 Select the output for the program in Figure A3. Pilih output berdasarkan program dalam Rajah A3. A Hi Hi B. No Ouput Tiada output C. Syntax error Kesalahan sintak D. Hi printed infinites times Hi dicetak sehingga infiniti 5 SULIT CLO2 | 12. Cc —————— el Figure A4/Rajah Ad Identify the C++ program that can produce the given output as Figure Ad, Kenalpasti program C++ yang BETUL bagi menghasitkan output yang diberi seperti di Rajah Ad. A int i=l; while (i <= 3) { if(i == 2) break; cout< Determine the suitable statement for X symbol in int main( ) ( ink i Ti dol cout<< i <<" " itt; ) ut : return 0; } Figure A6/Rajah A6 igure AG that produces output 123. Tentukan pernyataan yang sesuai bagi simbol X dalam Rajah A6 yang menghasilkan output 123 A. while (i<3) B. while (i<4) c. while (i<=4) D-—~ while (i<=2) SULIT CLO2 SULIT DFC2013: PROGRAMMING FUNDAMENTALS Cl cLo2 cl Datatype Array_name|size]; Figure A7/Rajah A7 Choose FALSE statement about declaration of one dimensional array in Figure A7. Pilih pernyataan yang SALAH tentang pengisytiharan tatasusunan satu demensi dalam Rajah A7. ‘A. Data type is the specifier that indicates what data type of variable Data_type merujuk kepada jenis data yang disimpan di dalam pemboleh ubah B. Array_name is the name of the declared array. Array name adalah nama bagi tatasususnan yang disytiharkan. C. Amay size defines how many elements the array can contain, Saiz tatasusunan merujuk kepada bilangan elemen di dalam tatasusunan, D. Array size must less than element that contain in array. Saiz talasusunan perlu kurang daripada element di dalam tatasususnan Identify the last and first elements for array number [13]. Kenalpasti elemen terakhir dan pertama dalam nunber[ 13]. A number [13], number [0] B. number [12], number [0] C. number [1], number [13] ) D. number [0], number {13}. 9 SULIT SULEE £62013 PROGRAMMING KUNDAMENTALS cxo2 |17 Cc tnt at SHAT A107 3 AT A Ar IO ts OTT cout< int main( ) { int store[3][2] = { {1,2}, (3,4), {9,8)}¢ cout<< x ; return 0; Figure Al0/Rajah A10 Choose the suitable statement for X that produces an output 9. Pilih pernyataan yang sesuai untuk X yang menghasilkan output 9. A B, G D. cout< struct planet ( char name[25]; string distant; Mi int main( ) { z = {"Mars", "78,340,000"}; cout<<"Planet :"< Choose the CORRECT statement to explain recursion, Pilih penerangan yang BETUL untuk menerangkan rekursif. A. Function that returns more than one value Fungsi yang memulangkan lebih dari satu nilai B. Function that calls themselves Fungsi yang memanggil diri sendiri CC. Funetion that passes value Fungsi yang menghantar data D. Function that calculates and receives value Fungsi yang mengira dan menerima nilai Select the INVALID function declaration. Pilih pengisytiharan fungsi yang TIDAK SAH. A. int Sum(int a, int b= 2, int © = 3); B, int Sum(int a = 5, int b); C. int Sum(int a= 0, int b, int D. Both B and C are incorrect. DFC2013: PROGRAMMING FUNDAMENTALS SULIT SULIT DFC2013: PROGRAMMING FUNDAMENTALS, CLO2 25. Identify the use of ampersand (&) symbol in funetion, cl Kenalpasti kegunaan simbol “ampersand” (&) dalam fungsi. ‘A. pass by value penghantaran dengan nilai B. pass by reference Penghantaran dengan rujukan C. Pass by statement Penghantaran dengan pernyataan D. Pass by function Penghantaran dengan fungsi CLO2 | 26. Choose declaration prototype for Display function which is not returned any values C2 and receives two float type parameters. Pilih pengisytiharan fungsi prototaip bagi fungsi Display yang tidak memulangkan nilai dan menerima dua parameter berjenis float A. float Display( float); B. void Display (float, float); C. float Display (); D. void Display (); CLO2 }27. Identify the operator represents the address of the pointer variable, cl Kenalpasti operator yang mewakili alamat bagi pembolehubah penunjuk A # Bf Cc & DR! 4 SULIT sun DEC2013 PROGRAMMING FUNDAMENTALS CLO2 | 28. Identify the pointer declaration of ptr. Cr Kenalpasti pengisytiharan penunjuk bagi ptr. A. int ptr; B. int *ptr; C. int &ptr; D. int ptr&; ee 29. float Quantity=12.50; Oo float Qptr: Qptr=sQuantity; Figure Al12/Rajah 412 Based on the segment code in Figure A12, choose the statement to display the value of Quantity. Berdasarkan keratan kod dalam Rajah A12, pilih pernyataan untuk memaparkan nilai Quantity. . cout<<&Quantity cout<<*Qptr, 2 Bl > cout< 16 SULIT CLO1 cl cLoL foil SULIT DFC2013: PROGRAMMING FUNDAMENTALS SECTION B: SSMARKS | BAHAGIAN B: SSMARKAH INSTRUCTION: This section consists of TWO (2) structured questions. Answer ALL questions. ARAHAN: Bahagian ini mengandungi DUA (2) soalan berstruktur. Jawab semua soalan. QUESTION 1 SOALAN I (a) i, List TWOQ) types of error in c+ programm Senaraikan DUA(2) jenis kesalahan di dalam atureara c++ [2 marks} ”) [2 markah] ii, Define debugging process in program Terangkan proses debugging dalam program [2 marks} [2 markah] {b) i. Define the terms below: Takrifkan item di bawah a) Identifier ; Pengecam > b) Variable Pembolehubah [4 marks] [4 markah} ii, List THREE (3) data types used in programming Senaraikan TIGA (3) jenis data yang digunakan dalam pengaturcaraan [3 marks} (3 markahy 7 SULIT { sue _rc2013: PROGRAMMING FUNDAMENTALS CLO |e) List TWO (2) types of repetition control structure, Ct Senaraikan DUA (2) jenis struktur kawalan pengulangan. . [2 marks} [2 markah CLO! |d) 3 for(int ico; 8 =; 8 te <<"Number of students :"<< _P_ <=18.5 && bmi<=24.5) output “Normal weight” D2 Ue net output “Overweight” Figure B2/Rajah B2 [6 marks} [6 markah] 18 SULIT cLo2 Cs while’. s DFEI1S: PROGRA: int main() { int i; for (i = 07 i < 5; i++) { cout << "Hello "7 cout << "There"<<"\n"; } return Figure B3/Rajah B3 FUNDAMENTALS £) Based on the program in Figure B3, convert for statement to do-while statement. Berdasarkan program dalam Rajah B3, tukarkan kenyataan ‘for’ kepada kenyataan ‘do- oO [5 marks] [5 markah] SULIT !: PROGRAMMING FUNDAMENTALS SULIT CLO2 |) List down TWO @) types of array. cl Senaraikan DUA (2) jenis tatasusunan. 1 mark] [1 markah] CLO2 |b) Identify the types of array shown in Figure B4 and Figure BS below: 2 Kenalpasti jenis tatasusunan berdasarkan Rajah I dan Rajah 2 di bawah: aft]} 6 ig a B 9 10 11 12. Figure BS/Rajah BS {1 mark] [1 markah] 20 SULIT SULIT DFC2013: PROGRAMMING FUNDAMENTALS CLO2 |c) — Write the terminologies in array ‘MyAlphabet’ based on Figure B6 below. Namatan istilah-istilah dalam tatasusunan “MyAlphaber” berdasarkan Rajah B6 di bawah. ii) MyAlphabet. i) {4 B {0} (a) Figure B6/Rajah B6 0 (3 marks] [3 markah] cLo2 | — 4) Based on the array declaration below, write the output. cl Berdasarkan pengisytiharan tatasusunan di bawah, tuliskan output. int number [7] = {1, 2, 4, 7,10,5 }; i. cout< using namespace std; void one(int x, inté y);} —» i) void two(inté s, int t); int a: |——+ ii) int main() { int u = 1; int v = 2; one(u, v)i << << << v << endl [even "in 0 cout << u << << v << endl; return 0; } void one(int x, ints y) { a xP i x= YF eee yrar } void two(int& s, int t) { int b: |—>+ v) bes-t; sst+b+2; t= 4 * b; } ) Figure B8/Rajah BS Based on the program in Figure BS, determine the element of function labelled i) until v). Berdasarkan program dalam Rajah BB, tentukan elemen di dalam fungsi yang telah dilabel i hingga v. marks] C [5 markah] 2B SULIT SULIT DFC2013: PROGRAMMING FUNDAMENTALS CLO2 [hy float Harga( float a, float b) c2 { a=at0.02*b; return a; } Figure B9/Rajah B9 ins below. Based on the function definition in Figure B9, answer the que: Berdasarkan takrifan fungsi dalam Rajah B9, jawab soalan di bawah. i) Identify the types of user define function based on the function definition above. Kenalpasti jenis fungsi takrifan pengguna berdasarkan takrifan fungsi di atas. [1 mark] [} markah] ii) Identify the data type used to return the value of a. Kenalpasti jenis data yang digunakan unutk memulangkan nilai a. [1 mark] [1 markah] Write the call function if the value of a and b are 500.0 and 5.0 respectively. Tuliskan fungsi panggilan jika nilai a dan b adalah 500.0 dan 5.0 [1 mark] [J] markah) iv)Calculate the return value of aif the value of a and b are 500.0 and 5.0 respectively. Kira nilai pulangan a jika nilai a dan b adalah 500.0 dan 5.0. [2 marks] [2 markah] 24 SULIT SULIT DFC2013: PROGRAMMING FUNDAMENTALS, CLO2 |i) Identify the terminologies used in memory allocation based on the declaration variable x in Figure B10-belo Kenalpasti istilah yang digunakan pada penempatan memori berdasarkan pengisytiharan pembolehubah dalam Rajah B10 di bawah. 7 1000 1002 1002 1003 1004 1005 noe ia mos | ta |e 0 Os] Han PE as Figure B10/Rajah B10 [3 marks] [3 markah) CLo2 |j) — Writea suitable code segment based on the statement in Figure B11 C2 Tuliskan kod segmen yang bersesuaian berdasarkan pernyataan dalam Rajah B11 int k float p 12.57 Figure B11/Rajah BI] () i) Declare the pointer variable kptr of type integer. Isytiharkan pembolehubah penuding kptr berjenis integer. [1 mark] [1 markah] ii) Assign the address of variable k to pointer variable kptr. Umpukkan alamat pembolehubah k kepada pembolehubah penuding kptr. {1 mark] [I markah] 28 SULIT SULIT DFC2013: PROGRAMMING FUNDAMENTALS, iii) Display the value of variable k. Paparkan-nilai pembolehubabe- he {1 mark] [1 markah] iv) Display the address of variable k. Paparkan alamat pembolehubah k. [1 mark] [1 markah] SOALAN TAMAT 26 SULIT

You might also like