












Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!













C
SUI-IT
SECTION A: 30 MARIG BAHAGIAN (^) A: 30 MARKATT
DF'C2O 13 PROGRAMMING F'UNDA}TENTALS
This (^) section consists of TWENTY (20) objective questions. (^) Mark your answers in the OMR form provideci.
dalam borang OMRyang disedio.kan.
clipenghujung pernyataan bahasq pengaturcardan (^) C "'"
A. Run (^) Time Error
B. Syntax Error
C. Logical (^) Eror
Ralat Pernyataan
#include <iostream.h>
int (^) main ( (^) ) 1 ( float (^) mark;
cout ((^ "Enter your (^) mark: cin )) marki rf (nark > (^) 50t
cout {{ (^) "fai}"; al c- cout(( (^) "pass";
ral-rrrn!g!u!rr nv, (^) " )
Syntax error
Run-time error Compile error
C
v
SULIT
C
C
CLO 1 C
a
SULIT (^) DFC20 (^13) PR.OGRAMMII'IG FUNDAIIE \ T {L S
Lcwtguage "?
A. cin>>Welcome to Programrning Language>>endl; B. cin))"Welcome to Programming Language (^) \n"; C. cout(( Welcome (^) to Programming Language<<endl, D. cout<<"Welcome to Prograrnming Language"<<end
B=10; ra-a, A=B*C+3;
A B c D ,r
l
A. (^) for B. while
C. if (^) .else
A. for (c:0; (^) c(:5; c++) B. for (c:0; c<:6; c++ (^) ) C. for (r:0; c<5' c++) D. for (c:0; (^) c<5; c++);
qTTS (^) T
e
C
C SULIT DFC2O13 PROGRA.MMING FU\DAf^ IE\T^ {L^ I
Array. int score[ (^) ]:{ I 0,20,30,a0}; i. The size element of the array is 4
ii. Scorefl]:10; iii. The type oleach element is^ integer Setiap elemen adalah^ herjenis^ integer iv. The name of the array is score Narua array adalal, score A. i and ii only / i^ dan ii^ sahaict B. iii and iv^ only I ii^ dan^ iv.sahaja C. i,^ iii^ and iv^ only^ I^ i,iii^ dcn^ iv^ sahc$a D. ii, iii and iv only I ii, iii dan iv sahaia
falasustrnan costnunt memegang data beriktrt:
What is the value in the variable costnum after the^ following^ statement^ is^ executed?
Apakah nilai pen$olehubah^ costnum^ selepas^ peny)ataan^ herikut dilaksanakan
A 49q B.25. c 3365 D 4599 SULIT 7
C
C
SULIT (^) DB.C2O 13 PROGRAMMXI{G FUNDAMENTALS
struct (^) workerTlpe (^) {
i-nt ID;
lwcrkcrl (^) ,worker2;
A, (^) workerl" worker 2 B. int ID C. workerType D. (^) struct workerType
B. (^) function declaration is terminated by the semicolon peng i (^) sytiharan fungs i b erakhir dengan semi kolon
C. function (^) declaration is similar to function call p e n gi syti har an (^) fungsi ada lah sama den gan .fun gsi me manggi I
D. function declaration must have the return type of the function
I)i antara berikut, manqkah sintak,vang BETUL untuk pengis,tiharan.firngsi?
function_name(parameter (^) li st) (^) ; return_type (parameter list) (^) fu nction*name,
.
A. B.
SITI,IT
SULIT DFC2O13^ PROGRAMMING^ F'UNDAIVIENTALS
#include (iost-ream) using namespace std;
int sum(int a, int^ b :^ 20) { int resul t;
result a - b;
return (resu-Lt^ ) ;
int main (^ )
int a :^ 100; int b :^ 2OA; int result;
-^-.,,1 rc>u.J.L +^ - >ul"ll\d/^rrm^ /- h\u)t^.
result :^ sunt(a) (^) ;
sysiem("pause"); return 0; )
A. Total value is^ :^ i
Total value is^ :^300
Total value is : 300
C.
SULIT
!,
!
Ci
C
{
SULIT DFC2O 13 PROGRAMMING FUND.{{^ E^ ^ T^ \L^ S
A. int ptr*;
B. int *ptr;
C int &ptr.
D. int ptr&;
A int ptr:^ i00; B int uptr:^ # C int ptr :^ 123456. D int *ptr:^ &123456.
SULIT
num [--*[l 123456 ou (^) [6fl rz34s
,J?34S
-.
C
C
BAHAGIAN (^) B: 70 MARKAIT DFC2O (^13) PROGRA]VIMING F'UNDAMENTAIS
This (^) section consists (^) of FOUR (4) qlrestions. (^) Answer ALL questions ARAIIAN:
SOAT-AN 1
Apakah ke sctla han^ sirnak?
Kenalpasri jenis data yang pctling ,sesuai bagi pembolehubah berikut.
monev age name crade [2 marks]
(ii) By using the answers in (b)(i), write the syntax to declare the variables.
Dengan menggunakan jawapon^ anda dakm (b)(r,^ tuliskan sintak untuk
[2 marks] l2 markahJ [2 marks]
i1 SULIT Y
Jawab soalsn^ berdasarkan Rajah^ Bl.
int x,y; x= 1; y= 1;
x=x1; y=yx; cout << x << "\t" <<^ y; )
Figure Bl^ I Rajah^ BI
i. How many times does program loops?
ii. (^) Write the output. Tulis output.
Tulis semulct kod segmen meruggunakan^ gelung do-while^.
int sum: 0; while(n >^ 0) { sum:sum*n; --n; I I
DTCzO 13 PROGRAMMING T'UNDAMENTALS
ft markahJ
[ 2^ marks ] l2markah J
.
a
C
C
C
C
SUT,IT
DTC2O 13 PROGRAMMING^ X'^ UNDAMENTALS
'I (^) u li s si ntak b agi pengi (^) sy ti har a n t a t as?t sunan.
'[ (^) uliskan pernyctaan C' (^) - urttuk...
i. declare an array my_array of 10 elements of type int.
ii. set the value of fifth element of array my_array to 3 5
iii. access the value of tenth element of array my_arrav.
int number (^) t3ll4l :^ { {2,4,6,8}"{3,6.9,12},{1,5,10,13} };
i. cout<<numberl2l[3];
ii, (^) cout<<number[0]121.
Kenal pasti dtta jeruisflmgsi.
iv. variable name is matrix consist 5 rows and 5^ coiumn lvith^ data t-vpe of^ double.
[ 2 marks^ ]
[ 4 marks^ ]
[ 2 marks^ ]
[2 marks] 12 markah)
l.t SULIT
C t -J'
C SULIT (^) DFC2O13 (^) PROGRAMMING FUNDAMENT,dLS (e) (^) Create a function name "calculate".It (^) will return a double (^) type data and accept a parameter (^) name testScore(<iata (^) type cioubie). Cipta satufung'ri (^) bernoma calculate. Furugsi (^) akan mengerubalikan tlata.jenis (^) clouble dqil
l2marksl [2markahJ
#include<iostream.h> void greet$;
void mainQ It greet$; department$. tt void department() {
) -'! ,rr.ction definition^ of^ greet I ) (f) i. (^) State the department (^) function prototype (^) on X label.
i2 marksl
12 martuh) ii. Write the definition of greet (^0) function (label (^) as Y) that can print "welcome" (^) as output. Tiiis delinisi (^) fungsi bagi gy eet 0 (label^ Y) yang (^) boleh mencetak perkataan (^) welcante ,sebagai output. f2 marksl 12 mcrrkah) 15 SIII,TT
C
C
C
C
SULIT
DF'C2013 (^) PROGRAMMING F'UNDAMENTAIS
[3 marks] [3 markah)
Nyalokan (^) definisi 'identifier' (^) di dalam bahasa pengaturcaraan (^) clan berikan (^) satil q)arst
[3 marks] 13 markahl
(c) (^) write cH statement (^) to accomplish the following (^) instructions.
Tulislran (^) pernyata*t c++ sngr|, (^) mememthi arshan-arahsrc berikut.
Declare three (3) (^) variables name x, y (^) and resurt as integer (^) aata tl.pe.
Print the message \Enter^ two integerrr.
Read two (2) integers from (^) the user and store them in the variables x and y.
Isytihar tiga (3) pembolehubah (^) x y dan (^) resuit di dalam kategori (^) inz
Papar pesattan tt4nter two integerrr.
[3 marks] [3 rnarkah
Senayaikan dan beri definisi dua jenis pengulangon.
[ 3 marks^ ] [3 markah^ I
(d)
L7 (^) STILIT
/-r r] C?
C
DFC2O 13 PROGRAMMING BUNDAMENTALS
If mark is more then 10, print^ a message"Very Good",
Jika mork adnloh lebih daripada l0 (^) , cetakmesej "^ Sangat^ Baik"^ ,
{3 markah^ it
Tuliskan kod segmen mengguruakan bahasa pengaturcarnant c-^ - untuk^ gelung^ while
4 Add counter using formula:
[3 marks] 13 markah)
18 SULIT
C
Ci
SULIT (^) DFC2O (^13) PROGRAMMING FUNDAMENTALS
return the result (which^ may contain (^) a decimal piace).
dcn (^) memulangkan nilcti (^) vang mengondurtgi titik perpuluhatt.
[3 marks]
13 marksl
(e) (^) What is a POLNTER (^) and give (^) declaration for POINTER
Terangkan maksttd POII\ITER don berikan (^) contoh bagi declat'cttton urttuk POINTER
20 SULIT
C
_t SUI-TT (^) DT'C2013 PROGRAMMINGFUNDAMENTALS (f) (^) Convert the following (^) algorithm into (^) C++ code: Tukarkan (^) algorithm berihfi kepada kod C., (^) -: Step i: Declare an array variable named Numlcer with size 3 of type integer. Langkah l: Isytihar pemboleh ubah tatax.rsunan l,Iumber dengan (^) sair 3 jeni.s tnLeqer.^ : ^+ ^-^
Langkah 2: Isytihar penuding^ Fnumber. Step 3: Assign Pnumber to variable Number.
Langkah 3: Ietapkatt Pnumber kepaCa pemboleh (^) ubah Number.
Langkah1; Tetapkannilai Pnunber kepada. 10. Step 5.^ Print^ the address of xumber (^) [0] krngkah 5: Paparkan alamat l,Junber (^) l}J. Step 6. Print the value (^) of object pointed (^) to by lTumber.
[3 marks] {j markah/
SOALAN TAMAT
CTTI I'r' Y